Delivery Status with Twilio

If you are using Twilio on your WordPress site you might be curios if your messages are being delivered. Twilio provides fine documentation on the delivery status system. https://www.twilio.com/docs/messaging/tutorials/how-to-confirm-delivery/php

In addition you can use this code snippet on your confirmation page to capture what is coming from Twilio.

$message = $twilio->messages
                  ->create("+15558675310", // to
                           [
                               "body" => "McAvoy or Stewart? These timelines can get so confusing.",
                               "from" => "+15017122661",
                               "statusCallback" => "http://yoursite.com/twilioconfirmation"
                           ]
                  );

On the /twilioconfirmation page you can place this code:

//connect to the database
if (isset ($_POST['AccountSid']) && $_POST['AccountSid'] == '<your Sid>'){
  if (isset ($_POST['MessageStatus'])&& isset ($_POST['MessageSid'])) {
      //Execute whatever code you need to executed to save the message status. You would most likely want to save it in a database.

  }
}