Sending picture messages from a website
Sending picture messages to phones is handy. Allowing people to send a photo from a website can be great for the purpose of sharing and getting the message out about on-going events and sales deals.
Sending these MMS messages works similar to SMS messages. The key difference is that we include a URL to our image files.
The new URL field is named MediaUrl
, which may sound familiar because we look for a similar field when we receive our messages.
We're going to use the TwilioMMS
class to send our MMS message with an image as shown in the following code snippet:
<?php class TwilioMMS{ public $sid; public $token; public function __construct($sid,$token){ $this->sid = $sid; $this->token = $token; } public function sendMessage($to,$from,$body,$murl){ $url = "https://api.twilio.com/2010-04-01/Accounts/{$this->sid}/Messages"; $data = array(); $data["To"]=$to; $data['From']=$from; $data...