-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlivo_Sample_Message_in_Coldfusion.cfm
41 lines (31 loc) · 1.45 KB
/
Plivo_Sample_Message_in_Coldfusion.cfm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<cfoutput>
#PlivoSendSMS('{dst}','Hi from Plivo')#
</cfoutput>
<!--------------------------------------------------------------------------------------------------------->
<!------------------------------------ PlivoSendSMS Function ---------------------------------------------->
<!--------------------------------------------------------------------------------------------------------->
<cffunction name="PlivoSendSMS" access="public" returntype="boolean" output="true">
<cfargument name="dst" type="string" required="yes" />
<cfargument name="text" type="string" required="yes" />
<cfoutput>
<!---set your account setting here--->
<cfset _src = '{src}'>
<cfset _AUTH_ID = '{AUTH_ID}'>
<cfset _AUTH_TOKEN = '{AUTH_TOKEN}'>
<!---build json record--->
<cfset _RetVal = true >
<cfset stFields = { "src" = "#_src#", "dst" = "#arguments.dst#", "text" = "#arguments.text#" }>
<!---send it--->
<cfhttp
method="post"
url="https://api.plivo.com/v1/Account/#_AUTH_ID#/Message/" result="request.getSMSS" >
<cfhttpparam type="header" name="Content-Type" value="application/json" />
<cfhttpparam type="header" name="Authorization"
value="Basic #ToBase64("#_AUTH_ID#:#_AUTH_TOKEN#")#" />
<cfhttpparam type="body" value="#serializeJSON(stFields)#">
</cfhttp>
<!---remove cfdump for production--->
<cfdump var="#request.getSMSS#">
</cfoutput>
<cfreturn _RetVal />
</cffunction>