Making a call using ColdFusion and the Twilio REST API

November 23, 2008
Written by
Twilio
Twilion

Twilio Bug Logo

Several people have asked for an example for initiating a call using ColdFusion and the Twilio Voice API. Here you go! Replace the parameters in the cfset statements, of course.

<!— Start a call from coldfusion —>

<!— enter your information for the following parameters —>
<cfset accountSid=”yourAccountSid”>
<cfset secret=”yourSecretKey”>
<cfset caller=”yourVerifiedCallerId”>
<cfset called=”phonenumberToCall”>
<cfset action_url=”urlToExecute”>

<!— make the rest request —>
<cfhttp url=”https://api.twilio.com/2008-08-01/Accounts/#accountSid#/Calls”
method=”POST”
username=”#accountSid#”
password=”#secret#”>
<cfhttpparam name=”Caller” type=”FormField” value=”#caller#”>
<cfhttpparam name=”Called” type=”FormField” value=”#called#”>
<cfhttpparam name=”Url” type=”FormField” value=”#action_url#”>
</cfhttp>

<!— display results —>
<cfoutput>
HTTP Response = #cfhttp.statusCode# <br>
<textarea cols=80 rows=10>
https://api.twilio.com/2008-08-01/Accounts/#accountSid#/Calls

#cfhttp.fileContent#
</textarea>
</cfoutput>