MMS with Twilio

MMS with Twilio SearchSearch
Author Message
John Bittner
New member
Username: Jbittner1002

Post Number: 1
Registered: 10-2015
Posted on Friday, October 09, 2015 - 09:31 pm:   

Were trying to get MMS to work with Twilio, we have SMS working but in order for MMS to work we need to have Medialurl including in the http post. Is there any way to add this? I did find some template files for twilio and I did try to add it there but is still does not work. Even if we have to set all messages out as MMS that will be ok , that is what we want for this gateway.
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 5483
Registered: 08-2008
Posted on Wednesday, October 14, 2015 - 02:24 am:   

Hi John,

Apologies for the delay in response. I needed to investigate this.

The short answer is that there is no way to make this work for MMS.

If there were a way to post the content as part of the transaction, we could make it work. This is how the standard MMS protocols work. But Twilio wants the MMS objects to be passed as an external URL reference (Mediaurl variable). There's no good way for NowSMS to do this.

It would be nice if they supported an API where the actual MMS content objects could be part of the HTTP POST.

--
Des
NowSMS Support
John Bittner
New member
Username: Jbittner1002

Post Number: 2
Registered: 10-2015
Posted on Wednesday, October 14, 2015 - 07:26 am:   

Des,

I did find a workaround.
I setup a php script based on the samples Twilio supplies for MMS on a Linux box with http access.
Hopefully this will help someone else.

I created a http sms gateway that posts to that script, set the email to allow 3 sms per email and tested.

The software is sending the messages in full to the Linux box, the php script adds the mediaurl and sends the MMS to Twilio.

Servers are private so only the NowSMS server can get to the Linux box so security in this script is light.
Sample code.

<?php
// this line loads the library for mms.php
require('/var/www/html/twilio-php/Services/Twilio.php');

$account_sid = 'AC1310a549549859d96f0b8503b305f3ecbeb';
$auth_token = '***********';
$client = new Services_Twilio($account_sid, $auth_token);
$client->account->messages->sendMessage("+12016907990", $_GET["to"], $_GET["body"], "http://**linuxip or hostname***/logo.bmp");

then in Nowsms put in http://==linuxip or hostname/ in Server host.
Under URL templates but this for both.
/mms.php?to=@@PhoneNumber@@&body=@@Text@@

leave all other boxes unchecked with the exception of routing
If anyone has any questions just email me direct john@xaccel.net
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 5484
Registered: 08-2008
Posted on Wednesday, October 14, 2015 - 02:28 pm:   

Hi John,

Thanks for the info.

If you are always using the same MediaURL, it is possible to configure NowSMS to connect directly to Twilio, which might simplify your setup.

Let me explain how.

I'll start by explaining how to connect to Twilio for 2-way SMS (send+receive), then modify the template to include Mediaurl so that the message goes out via MMS instead of SMS.

Define an HTTP SMSC in NowSMS, and for "Server Type", select Twilio.

Enter the Account SID as "User Name", and the Auth Token as "Password".

The Twilio phone number should be defined as the "Sender Address".

Uncheck the various options except for "Send long messages without segmentation", which should be checked.

Set routing parameters as appropriate for your system.

Here's an example:



To receive inbound SMS from Twilio, you need to configure an SMS URL in your phone number settings in Twilio.

If your NowSMS server is accessible over the internet, use http://server:8800/inboundsms/twilio

If not, don't worry as NowSMS will poll Twilio every 30 seconds for new messages. However, our experience is that this polling only works if you have a URL defined for inbound SMS on Twilio, otherwise Twilio discards the message. I've used a URL of http://twilio.com to get around this.

Once you've got SMS working, you can find the Twilio template under the NowSMS install at HTTPSMSC/Twilio

sendtext.txt is the sending template where you would add Mediaurl...NowSMS will URL escape parameters that it adds, but you need to URL escape this one.

If you decide to modify the template, I'd suggest copying the 3 files from HTTPSMSC/Twilio to a new directory under HTTPSMSC, and select that as the "Server Type" in the HTTP SMSC definition. This way, if we update the default template in a new version, it will not affect your setup.

--
Des
NowSMS Support