Skip to main content

Sending SMS/MMS text messages via Twilio and ColdFusion in 5 minutes or less

Wow, almost exactly a year since my last post.   How some things change and other things don't.

On the one hand my father has passed away almost a year ago and that has left a big hole in our lives.  On the other hand a year ago BitCoin was at it's peak and was days away from jumping off the cliff.  Well it fell from about $19,000 all the way to $6000 where it has held for many months...until yesterday when it jumped off the cliff again. 

On to Twilio - I'm blown away with how easy it is to get communication components accomplished with Twilio.  We are using it for normal SMS text messages at TapCloud.  We also use it to send out our Authy based 2-Factor authentication tokens, and we are starting to use it for peer-to-peer and one-to-many video conferencing.

One of the great things about Twilio is just how easy it is to use.  Here's an example of just a handful of code that will let you go from start to finish so you'll be sending out MMS messages in about 5 minutes.  For those that don't know, MMS messages appear just like text messages (SMS) but they can also include media such as video, images, and sound.  MMS stands for Multimedia Messaging Service which is a lot harder to say than MMS.

Cutting to the chase, here's the ColdFusion code.  Obviously, use your own Auth Credentials which you can easily get by signing up with Twilio (www.twilio.com).  Due credit, this is based a lot on a very similar example by Ben Nadel.



twilio.accountSID = "111111";
twilio.authToken = "2222222";
twilio.phone = "+18475555555";
mediaUrl = "https://app.tapcloud.com/s/assets/sodiumfacts2.pdf";

twilioRequest = new Http(method = "post",
url = "https://api.twilio.com/2010-04-01/Accounts/#twilio.accountSID#/Messages",
username = twilio.accountSID,
password = twilio.authToken
);

twilioRequest.addParam(
type = "formfield",
name = "From",
value = twilio.phone
);

twilioRequest.addParam(
type = "formfield",
name = "To",
Value = "+18475555555"
);

twilioRequest.addParam(
type = "formfield",
name = "MediaUrl",
value = mediaUrl
);

twilioRequest.addParam(
type = "formfield",
name = "Body",
value = "The Doctor has asked that you follow these Salt guidelines for today:"
);

result = twilioRequest.send();



Done!



Believe it or not, that's all it is to it.  You are using your Twilio phone number in one variable, your destination phone number in another, and an URL pointing to your multimedia object in yet another variable.  Save that as a .CFM and run it and you'll be sending MMS messages to your heart's content.

Comments

  1. I like the work which you have placed in this article. This data is significant and superb. I might want to thank you for sharing this article here. affordable text marketing

    ReplyDelete
  2. Thanks for this... very easy to grasp. I find Nadel's examples too much. This is straight to the point.

    ReplyDelete
  3. This is very nice, and I have it saving all sent messages in a database. But the question I have is how to save the return messages in a database, including the MediaURL data if someone send a picture back in response

    ReplyDelete
  4. Also, how do you get the Twilio smsSID data back from Twilio when you send a message?

    ReplyDelete

Post a Comment

Popular posts from this blog

Etherum on the Move...

Artwork by Steven Grundy What, more Crypto talk? Yes, sorry, more crypto talk, but I'll try to keep it short. Back on July 16th I said that I thought the bear market had ended that day and we were starting a new bull market. Only time will tell if I was right because we haven't had enough time to call it a bear market. But, in that time, Ethereum, the bellwether coin that we measure with, is already more than 50% from that date and 120%+ since June 16th (2022). There are a lot of coins that did better than that, but for a "safe" bet like Ethereum, that's a really nice move. But, it's not too late. Ethereum makes a change on September 26th that will dramatically improve it's capabilities. I think we are going to fairly quickly see ETH return it, and pass it's all time high of $4891.70, maybe even before the end of the year. Now there is always the chance that ETH, and all coins, will turn around and head back down for a test of the low of $876.54....

Troubleshooting a Discourse Update on DigitalOcean: Resolving Unresolvable Errors

For the past three years, I've maintained a Discourse server on a DigitalOcean Droplet. Recently, I decided to update it with some of the latest Discourse features. What I anticipated to be a straightforward update process turned into several days of frustrating setbacks. The version of Discourse I was running was already three years old, so I assumed that running the built-in "Update" feature would suffice. However, after clicking the update button, the progress bar sluggishly crawled forward over the next half hour, only to display the dreaded message: "Error – Update Failed." The logs provided little to no help, but based on my experience with other software updates via GIT, I suspected that the failure might be due to the repository head still being called "Master." In recent years, there has been a shift away from using "Master" as the repository head, with "Main" becoming the preferred term. Despite trying several methods ...

Antiminer S7 Issues and Diagnostics steps

Note, the instructions below are how I diagnosed the problem I describe.  I'm providing it here in case these steps help you narrow down your issue somewhere along the way. I have an Antminer S7 (batch 8) unit that has been giving me problems.  It worked fine for a week or so then started slowing down.  I could hear the fan slowing down and speeding up and if I checked the web GUI of the unit I could see that “chains” 1 and 3 often had very cool temperatures, as if they weren’t even running. It would then try to get those engaged again and it would speed up and then the cycle would repeat.  Eventually, over time, I’d get a high piercing alarm sound and at that point if I checked the GUI I’d see Xs in the ASIC display instead of Os (image below). Above is how it was typically running.  After a while an alarm would sound and it would look like below: PSU: The first things I tried were to swap power supplies with a working unit.  It’s...