Skip navigation
Currently Being Moderated

sms status

Mar 6, 2009 8:55 AM

Hi i have setup the sms utility and its working well sending sms, i now need to get the status of the sms back into my system,

i am just using the main.cfc but i am not sure what to do here?

all i want to do is have a sql stored proc update my database by passing in the Status and the id number from the sent sms.

<cffunction name="onBuddyStatus">
<cfargument name="CFevent" type="struct" required="YES"/>
<cfstoredproc procedure="spUpdateStaus" datasource="#datasource#">
<cfprocparam type="In" cfsqltype="cf_sql_varchar" dbvarname="ReferenceNumber" value="#ReferenceNumber#" null="No">
<cfprocparam type="In" cfsqltype="cf_sql_varchar" dbvarname="Status" value="#Status#" null="No">
</cfstoredproc>
</cffunction>
 
Replies
  • Currently Being Moderated
    Mar 6, 2009 11:37 PM   in reply to kel45
    OnBuddyStatus is for IM. For SMS, use onIncomingMessage. That is the name Coldfusion expects. However, if you insist on onBuddyStatus then you have to set the value of cfc-method in your SMS configuration file to onBuddyStatus.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 10, 2009 3:08 PM   in reply to kel45
    Yes, the stored procedure will run when you put it in onIncomingMessage. That will happen automatically. The list of variables that come in automatically are those in the SMS cfevent structure. You have to find a way to pass any variables not in the list.


     
    |
    Mark as:
  • Currently Being Moderated
    Mar 11, 2009 3:59 PM   in reply to kel45
    Have you checked that the following runs on an ordinary CFM page?

    <cfmail to = "email" type="html" from = "email" subject = "income test"
    username = "email" password = "email" server = "email" port = "25">
    test message
    </cfmail>


     
    |
    Mark as:
  • Currently Being Moderated
    Mar 16, 2009 11:17 PM   in reply to kel45
    Come to think of it, there is no reason for you to be sending email within an SMS gateway. In fact, if I remember well, previous postings have suggested it might not even be possible to do so. I am looking into this and asking around.

    Have a look at Kevin Schmidt's article, Sending messages through ColdFusion SMS gateways. It includes code for a complete working implementation of the SMS gateway.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 17, 2009 12:54 AM   in reply to kel45
    BKBK wrote:
    > Come to think of it, there is no reason for you to be sending email within an
    > SMS gateway. In fact, if I remember well, previous postings have suggested it
    > might not even be possible to do so. I am looking into this and asking around.

    huh?
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 17, 2009 2:51 AM   in reply to BKBK
    kel45 wrote:
    > i can send sms find using what i have, its the sms status i need to get via

    what do you think "SMS status" is?
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 17, 2009 4:42 AM   in reply to Newsgroup_User
    kel45 wrote:
    > DR format:
    > ?id:<message_id> sub:<message_sub> dlvrd:<message_dlvrd>
    > submit date:<message_submit_date> done date:<message_done_date>
    > stat:<message_stat> err:<message_err>?

    and the delivery receipt is what you mean by "SMS status"? or are do you mean
    what's returned when you send the SMS (if your gateway's in synchronous mode
    that should be the SMS message ID)?

    so...is your SMS gateway config "mode" set to "synchronous"? and your SMS
    provider actually returns something in this mode for your out-going phone
    numbers? have you tested against the SMS test server that comes w/cf?


     
    |
    Mark as:
  • Currently Being Moderated
    Mar 17, 2009 9:52 AM   in reply to Newsgroup_User
    kel45 wrote:
    > hi yes "mode" set to "synchronous" and i do get the message id back, but how do i know what the message status is?

    if you get a message ID back then it's delivered (at least out of your cf server
    & to your SMS provider). save the ID & wait for the SMS provider to send a
    delivery receipt (as long as you set "registeredDeliver" on the outgoing SMS &
    the SMS provider supports this for your out-going phone numbers/regions).

    by "wait for the SMS provider" i mean for each incoming SMS you have to check to
    see what type of SMS message it is by examining the CFEvent.Data.esmClass data.
    if it's a delivery receipt you match it's ID up with the out-going message ID
    you saved from the sendGatewayMessage(). i *think* the esm class codes are
    something like:

    0==normal SMS
    1==delivery receipt
    2==delivery acknowledgment
    3==no idea
    4==manual delivery acknowledgment
    5==no idea
    6==no idea provider dependent (i *think*)
    7==no idea
    8==intermediate delivery notification (somewhere along the network something has
    received the SMS but not final recipient).

    get a copy of the SMS 3.4 specs PDF (free, all over the place) to be sure of the
    codes. don't expect the delivery receipt to be synchronous just be prepared to
    handle it whenever you get an SMS in.
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 17, 2009 10:40 PM   in reply to kel45
    PaulH wrote:
    huh?

    Have you succeeded in sending mail by implementing <cfmail> within the listener CFC of the SMS gateway? I haven't. If you have, could please show us the code you used.


     
    |
    Mark as:
  • Currently Being Moderated
    Mar 17, 2009 11:00 PM   in reply to kel45
    BKBK wrote:
    > PaulH wrote:
    > huh?
    >
    > Have you succeeded in sending mail by implementing <cfmail> within the listener CFC of the SMS gateway? I haven't. If you have, could please show us the code you used.

    yup, works fine on cf8, no rocket science here.

    <cffunction name="onIncomingMessage" output="no">
    <cfargument name="CFEvent" type="struct" required="yes">
    <!--- Get the message --->
    <cfset data=cfevent.DATA>
    <cfset message="#data.message#">
    <!--- where did it come from? --->
    <cfset orig="#CFEvent.originatorID#">
    <cfset retValue = structNew()>
    <cfset retValue.command = "submit">
    <cfset retValue.sourceAddress = arguments.CFEVENT.gatewayid>
    <cfset retValue.destAddress = arguments.CFEVENT.originatorid>
    <cfset retValue.shortMessage = "echo: " & message>
    <cflog file="smsTestCrapola" text="going to send some email now...">
    <cfmail to="paul@sustainableGIS.com" from="paul@sustainableGIS.com" subject="SMS
    gateway test">
    just a test: #retValue#
    </cfmail>
    <cfreturn retValue>
    </cffunction>

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 18, 2009 11:17 AM   in reply to Newsgroup_User
    kel45 wrote:
    > Hi i have tested your code exactly but i still get no email i do however get a
    > logfile entry

    i get email when i tested against the test SMS server that comes w/cf8.

    > so i tried doing this
    > <cflog file="smsTestCraig" text="#retValue#">
    > but then i get no entry?

    because retValue is not a simple variable, it's a structure.

    > how can i test adding the retValue to the logfile?

    output the individuals parts.

    looks like one of my messages didn't get thru the NNTP gateway & i deleted it
    from the sent folder.
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 18, 2009 11:20 AM   in reply to Newsgroup_User
    kel45 wrote:
    > onIncomingMessage to send me an email just to test this, buti never get the
    > email and my provider has checked and they did send the registeredDelivery

    did you check your undelivered email folder?

    > <cffunction name="onIncomingMessage>
    > <cfargument name="CFEvent" type="struct" required="yes">
    > <!--- Get the message --->
    > <cfset data=cfevent.DATA>
    > <cfset message="#data.message#">
    > <!--- send the return message back --->
    >
    > <cfmail to = "email" type="html" from = "email" subject = "income test"
    > username = "email" password = "email" server = "email" port = "25">

    are you really using "email" for the to/from/etc.?

    > <cfdump var="#data#">
    > </cfmail>
    > <cfreturn retValue>
    > </cffunction>

    retValue isn't created/used anywhere in that function. have you looked at your
    exception logs? are they by any chance full of errors?




     
    |
    Mark as:
  • Currently Being Moderated
    Mar 19, 2009 8:32 PM   in reply to Newsgroup_User
    PaulH wrote:
    yup, works fine on cf8, no rocket science here.

    <cffunction name="onIncomingMessage" output="no">
    <cfargument name="CFEvent" type="struct" required="yes">
    <!--- Get the message --->
    <cfset data=cfevent.DATA>
    <cfset message="#data.message#">
    <!--- where did it come from? --->
    <cfset orig="#CFEvent.originatorID#">
    <cfset retValue = structNew()>
    <cfset retValue.command = "submit">
    <cfset retValue.sourceAddress = arguments.CFEVENT.gatewayid>
    <cfset retValue.destAddress = arguments.CFEVENT.originatorid>
    <cfset retValue.shortMessage = "echo: " & message>
    <cflog file="smsTestCrapola" text="going to send some email now...">
    <cfmail to="paul@sustainableGIS.com" from="paul@sustainableGIS.com" subject="SMS
    gateway test">
    just a test: #retValue#
    </cfmail>
    <cfreturn retValue>
    </cffunction>


    Rocket science or not, that couldn't have worked. I expect Coldfusion to halt at the line, just a test: #retValue#. You cannot output a structure like that. Still, I take the point that you have a working version.



     
    |
    Mark as:
  • Currently Being Moderated
    Mar 20, 2009 7:03 AM   in reply to Newsgroup_User
    BKBK wrote:
    > just a test: #retValue#
    >
    > Rocket science or not, that couldn't have worked. I expect Coldfusion to halt
    > at the line, just a test: #retValue#. You cannot output a structure like
    > that. Still, I take the point that you have a working version.

    yeah you're right that's supposed to be retValue.message. must have deleted it
    when formatting for the forum.

    are you sure you're not getting the email? nothing silly like wrong server,
    etc.? SMS working ok? what SMS server did you use? besides this thread, any
    other reports of this issue?

    in any case, i'll double check that i'm not doing anything silly.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 20, 2009 10:56 PM   in reply to Newsgroup_User
    BKBK wrote:
    > that. Still, I take the point that you have a working version.

    i just re-tested & i an confirm 2 things:
    - cfmail certainly works in an SMS gateway listener
    - & i'm an idiot when it comes to moving code from editors to other
    things...that of course should be "retValue.shortMessage".
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 20, 2009 11:14 PM   in reply to kel45
    PaulH,

    No need. The first time you said it works, I took it for granted it works. I've been busy debugging myself.
     
    |
    Mark as:
  • Currently Being Moderated
    Mar 20, 2009 11:19 PM   in reply to kel45
    Myself? Oops, I see the double-meaning just now. Oh, and thanks, Paul, for the guidance.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 21, 2009 11:19 AM   in reply to BKBK
    I got it to work. That means Kel45 and I have been missing some steps.

    Here then are the steps I followed.

    1) Save the following as the file C:\Coldfusion8\sms_gw\smsListener.cfc
    ======================================================

    <cfcomponent>
    <cffunction name="onIncomingMessage">
    <cfargument name="cfEvent" required="yes" type="struct">

    <cfset var msg = arguments.cfEvent.data.message>
    <cflog file="smsTestRecord" text="sms log message">
    <!--- Use actual e-mail addresses --->
    <cfmail to="email1@domain1" from="email2@domain2" subject="SMS gateway test">
    <cfoutput>#msg#</cfoutput>
    </cfmail>
    <cfreturn>
    </cffunction>
    </cfcomponent>

    2) Save the following as the file C:\Coldfusion8\sms_gw\config\smsConfig.cfg
    ==========================================================

    #
    # SMSGateway configuration file
    # Test server config
    #

    # This is the IP address of SMSC
    ip-address=127.0.0.1

    # Port to bind to
    port=7901

    # Your system id
    system-id=cf

    # Your password
    password=cf

    # The source address for this client
    source-ton=1
    source-npi=1
    # This is a made-up address
    source-address=5551213

    # The address range this smpp client will serve
    # Generally the same as your source address
    addr-ton=1
    addr-npi=1
    address-range=5551213

    # Message sending rate; how many messages per second is the
    # gateway allowed to send to your service provider.
    # This can be a decimal (i.e. 0.1). 0 is unlimited.
    # The default is 100 messages per second.
    message-rate=100.0

    # The mode of the gateway; Either synchronous or asynchronous
    # In synchronous mode the gateway will wait for the response
    # from the server when sending a message and the SendGatewayMessage()
    # CFML function will return the SMS messageID of the message
    # or an empty string if their is an error. In asynchronous mode,
    # the gateway will not wait for a response and the SMS messageID
    # will NOT be returned from SendGatewayMessage().
    # The default is synchronous.
    mode=synchronous

    # Should the gateway retry delivery on Network Errors?
    # If a network error occurs while trying to deliver a message,
    # should the message be queued for delivery when the gateway
    # is able to re-bind to the SMSC. This is useful if the gateway
    # is in asynchronous mode, where no error status is returned from
    # the CFML SendGatewayMessage() function.
    # The default is no.
    network-retry=no

    # Should the gateway retry delievery on Transient Errors?
    # If an error is returned from the SMSC that indicates
    # the message may be able to be delivered in the future,
    # should the gateway attemp to resend send the message?
    # This is useful if the gateway is in asynchronous mode,
    # where no error status is returned from the CFML
    # SendGatewayMessage() function.
    # The default is no.
    transient-retry=no

    ##################################################
    # Everything below here is usually OK.
    ##################################################

    # The function in the Gateway CFC which the is called
    # when an incoming message arrives.
    #
    cfc-method=onIncomingMessage

    # The default destination address info
    destination-ton=1
    destination-npi=1
    # You can't have a default destination
    # destination-address=


    # The service type can be empty or one of
    # the following values:
    # CMT, CPT, VMN, VMA, WAP or USSD
    # service-type=

    # From the spec:
    # Identifies the type of system requesting the bind.
    # This may enable SMSC responses which are
    # particular to a given type of ESME.
    system-type=SMPP

    # The receive timeout is a timeout for trying to receive a message
    # from the SMSC. If you want go to infinite wait until a PDU
    # is received, set the receive-timeout to -1.
    # The value is in seconds. The default is 30 seconds.
    receive-timeout=10

    # The ping interval is how often the SMS Gateway will send an
    # EnquireLink PDU to the server to verify the health of the connection.
    # The value is in seconds. The default is 60 seconds.
    ping-interval=60

    # The number of connection attempts the gateway will make until it gives up.
    # Use -1 to retry until connected. The default is -1 (try forever).
    retries=-1

    # Connection retry interval; how long to wait between connection attemps.
    # The value is in seconds. The default is 10 seconds.
    retry-interval=10


    3) On the Gateway Settings page in the Administrator, start the SMS Test Server.
    =============================================================

    4) On the Gateway Instances page in the Administrator, add the following new instance
    =================================================================

    Gateway ID: smsTest
    Gateway Type: SMS - Handles SMS text messaging
    CFC Path: C:\Coldfusion8\sms_gw\smsListener.cfc
    Configuration File: C:\Coldfusion8\sms_gw\config\smsConfig.cfg
    Startup Mode: Automatic

    5) Start the SMS instance.
    =====================

    If necessary, press the Refresh button after a few seconds to go from 'Starting' to 'Running'.

    6) In C:\Coldfusion8\bin, double-click on SMSClient.bat to start the client
    =======================================================

    7) Click on the Connect button
    ========================

    8) Enter the value 5551213 in the field 'Send SMS to:'
    =========================================

    That is the value in the configuration file.

    9) Enter some text (e.g. Eureka! It works!) in the message field. Press Send.
    =========================================================

    10) Check the email account and Coldfusion log directory to confirm it worked
    =========================================================




     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points