I'm trying to integrate Twilio onto my Wordpress site.
The idea is to allow users to type in their phone number to get a download link to our app. We've put up a simple form here - http://evntr.co/download - and upon submitting the form, the EvntrPHP.php code is run.
Using template code, we've easily been able to get the form to send a message to a verified number (the one currently in the To field) using a free Twilio number. However, when we add the StatusCallback parameter, it never calls our callback.php code. Both EvntrPHP.php and callback.php are in the root directory - evntr.co/.
<?php require 'twiliophp/Services/Twilio.php'; $AccountSid = "--------"; $AuthToken = "---------"; $client = new Services_Twilio($AccountSid, $AuthToken); $phonenum = $_POST["phonenum"]; $callbackURL = "https://evntr.co/callback.php"; $client->account->messages->create(array( 'To' => "XXXXXXXXXX", 'From' => "+XXXXXXXXXX", 'Body' => "Test Message", 'StatusCallback' => "https://evntr.co/callback.php", )); ?>
My understanding is that the flow should be like this:
- user navigates to evntr.co/download
- user submits the form with their number
- form calls EvntrPHP.php and sends a text message to their number
- Twilio POSTs to callback.php whenever the status of the message changes (Sent, Delivered, Canceled, etc).
However, every time I submit the form, the message is sent and the page just stays at evntr.co/EvntrPHP.php and never loads callback.php. Maybe this is a misunderstanding on my part with how Callback URLs work? Or maybe the StatusCallback parameter doesn't work with a free Twilio number?