Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Receiving SMS and storing it in database using Twilio

i am using Twilio API to send and receive sms from the customers.

Every time i send the sms to my customers, i store the feilds like to, body in to my database.

I have implemented the API for send message that works fine and am simply saving the fields in to my database.

My Problem

When i receive SMS from my customers to my twilio number. i want to get the fields like from number and the body and save to my databse.

i looked that the documentation here

https://www.twilio.com/docs/api/twiml

https://www.twilio.com/blog/2012/04/get-started-with-twilio-sms-receiving-incoming-sms-quickstart.html

But this only shows how to send a response to customer when a message is received.

I want to save the received sms in to my database.

Can someone help me top get the from number and the message body when a SMS is received. tnx..

like image 382
Sathya Baman Avatar asked Oct 19 '22 10:10

Sathya Baman


1 Answers

Twilio evangelist here.

Twilio passes parameters in its HTTP request as form-encoded values, so you just need to use the REQUEST object to grab them:

$from = $_REQUEST['From']

The SMS Quickstart for PHP has a more detailed example.

Hope hat helps.

like image 85
Devin Rader Avatar answered Oct 27 '22 20:10

Devin Rader