Synchronization mode

You can specify asynchronous or synchronous message mode in the gateway configuration file.

Use synchronous mode if your application must determine whether its messages reach the SMSC. Also use synchronous mode if the application requests return receipts.

Note: If you use synchronous mode and the SMSC returns the messgeID as a hexadecimal string, ColdFusion MX converts it automatically to its decimal value.

The following example is an expansion of Example: Using the submit command in sendGatewayMessage function. 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 MX is installed. If you change the gateway specified in the SendGatewayMessage function, make sure that you 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>

View comments in LiveDocs