Avg. Rating 4.0

Problem

You want to send a text message from ColdFusion

Solution

Use the Clickatell API and the CFHTTP tag to send a message

Detailed explanation

 It's really simple to create and send a text message to a mobile phone using the Clickatell API from ColdFusion.  We'll be building an XML document that will be posted to their web api using CFHTTP.

Step 1: Build the XML document with the data we want to send. 
 
<cfsavecontent variable="xmlData">
<cfoutput>
<clickAPI>
<sendMsg>
<!--- the API ID is set up in the Clickatell admin --->
<api_id>999999</api_id> 
<!--- your username and password for the service --->
<user>#api_username#</user>
<password>#api_password#</password>
<!--- the "source" phone number (usually your own) --->
<from>12155551212</from>
<!--- the destination phone number - digits only --->
<to>16105551212</to>
<!--- the message you want to send --->
<text>ColdFusion rocks!</text>
</sendMsg>
</clickAPI>
</cfoutput>
</cfsavecontent>
 
Step 2: Post that data to Clickatell using the CFHTTP tag
 
<cfhttp url="http://api.clickatell.com/xml/xml" method="POST" resolveurl="false" result="result">
<cfhttpparam type="FORMFIELD" name="data" value="#xmlData#" />
</cfhttp>

 


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes