How to handle my sms statuscallback in twilio using php laravel?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How to handle my sms statuscallback in twilio using php laravel?



I saw an example in twilio: https://www.twilio.com/docs/sms/tutorials/how-to-confirm-delivery-php


<?php
$sid = $_REQUEST['MessageSid'];
$status = $_REQUEST['MessageStatus'];

openlog("myMessageLog", LOG_PID | LOG_PERROR, LOG_USER);
syslog(LOG_INFO, "SID: $sid, Status: $status");
closelog();



I don't know what the code above exactly do, but what I want is to save the data to my local database.



The code in my post method(my statuscallback):


public function smsStatusCallback(Request $request)

$sms = SmsChannel::create([
'number' => $request['MessageSid'],
'body' => $request['MessageStatus'],
]);




1 Answer
1



I've found a solution already. I saw the possible solutions in twilio debugger: "Double check that your TwiML URL does not ...". So I tried making it as a twiml


public function smsStatusCallback(Request $request)

$response = new Twiml();

$sms = SmsChannel::create([
'sid' => $request['MessageSid'],
'status' => $request['MessageStatus'],
]);

return response($response)
->header('Content-Type', 'text/xml');




I've added my route to api.php since the URL should be accessible by twilio.


Route::post('sms-status-callback','CommunicationController@smsStatusCallback');






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard