
1304
DEVELOPING
COLDFUSION 9 APPLICATIONS
Using External Resources
Las
t
upda
te
d 8/5/2010
The following example is an expansion of
Example: Using the submit command in sendGatewayMessage function
discussed in “
The submit command
” on page 1300. It checks for a nonempty return value and displays the message
number returned by the SMS. This example uses the SMS gateway that is configured when ColdFusion is installed. If
you change the gateway specified in the
SendGatewayMessage
function, make sure that your gateway’s configuration
file specifies synchronous mode.
<h3>Sending SMS From a Web Page Example</h3>
<cfif IsDefined("form.oncethrough") is "Yes">
<cfif IsDefined("form.SMSMessage") is True AND form.SMSMessage is not "">
<h3>Sending a Text Message: </h3>
<cfoutput>#form.SMSMessage#</cfoutput><br><br>
<cfscript>
/* Create a structure that contains the message. */
msg = structNew();
msg.command = "submit";
msg.destAddress = "5551234";
msg.shortMessage = form.SMSMessage;
ret = sendGatewayMessage("SMS Menu App - 5551212", msg);
</cfscript>
</cfif>
<cfif isDefined("ret") AND ret NEQ "">
<h3>Text message sent</h3>
<cfoutput>The Message Id is: #ret#</cfoutput>
<br><br>
</cfif>
<hr noshade>
</cfif>
<!--- begin by calling the cfform tag --->
<cfform>
SMS Text Message: <cfinput type="Text" name="SMSMessage"
value="Sample text Message" required="No" maxlength="160">
<p><input type = "submit" name = "submit" value = "Submit">
<input type = "hidden" name = "oncethrough" value = "Yes">
</cfform>
Optional parameters for outgoing SMS
You can send vendor-specific optional parameters by way of ColdFusion SMS gateway.
To set the optional parameters, specify them using the
optionalparameter
attribute.
If the gateway receives optional parameters in a message, they are included in the data struct that is returned to the
listener CFC method named
onIncomingMessage
under the
optionalParameters
key.
The following code describes how to add optional parameters:
params=StructNew();
params["
parameter
"]=BinaryDecode("
string
","
binaryencoding
");
params["parameter"]=CharsetDecode("
string
,
encoding
");
outgoingSMS.optionalParameters=params;
•
parameter
: Vendor-specific optional parameter.
•
BinaryDecode
: See BinaryDecode in
CFML Reference.
•
CharsetDecode
: See CharsetDecode in
CFML Reference.
Содержание COLDFUSION 9
Страница 1: ...Developing Applications ADOBE COLDFUSION 9...