Receiving MMS messages
First, let's learn how to receive picture messages. This is similar to how we receive text messages; the only difference is that picture messages using MMS also include a field named MediaUrl
, which contains the URL that was attached to the message.
We will begin by setting up a file named listener.php
, which is where we will configure Twilio to send our messages. This script will store all incoming messages in a MySQL database and download the attached image locally. Then we will set up a file named messages.php
, which will display the message along with the image.
Getting ready
The complete code for this recipe can be found in the Code/Recipe1
/ folder.
How to do it…
Let's set up our listener.php
file to store all incoming messages and messages.php
to view messages we've received.
Upload
config.php
to your web server with the following code:<?php $accountsid = ''; // YOUR TWILIO ACCOUNT SID $authtoken = ''; // YOUR TWILIO AUTH TOKEN $fromNumber = ...