Use Twilio to receive SMS and MMS messages. For a step-by-step tutorial see the Twilio docs.
Twilio supports HTTP Basic and Digest Authentication. Authentication allows you to password protect your TwiML URLs on your web server so that only you and Twilio can access them.
Learn more about HTTP authentication here, which includes sample code you can use to secure your web application by validating incoming Twilio requests.
This project is built using the Sinatra web framework.
-
First clone this repository and
cd
into it$ git clone git@github.com:TwilioDevEd/receive-mms-sinatra.git $ cd receive-mms-sinatra
-
Install the dependencies
$ bundle install
-
Run the server
$ ruby app.rb
-
Expose your application to the wider internet using ngrok. This step is important because the application won't work as expected if you run it through localhost.
$ ngrok http 4567
Once ngrok is running, open up your browser and go to your ngrok URL. It will look something like this:
http://<yourdomain>.ngrok.io
You can read this blog post for more details on how to use ngrok.
-
Configure the Twilio Phone Number SMS Webhook
On your Twilio Number dashboard, configure the incoming SMS Webhook to the following address:
http://<yourdomain>.ngrok.io/sms
-
Send a SMS to your number with one or more images, and see them saved locally on your folder!
- No warranty expressed or implied. Software is as is. Diggity.
- MIT License
- Lovingly crafted by Twilio Developer Education.