SMS Notify! PostBackURLs

From CDYNE Wiki
Jump to: navigation, search

Know when your text messages were sent or received. The CDYNE SMS Notify! API will automatically post information to a URL you specify when text messages are sent or received via DIDs or short codes. PostBackURL data is posted behind the scenes, and is not visible on your webpage. Code samples are provided below on how to capture this data to store in a database. CDYNE recommends that the data returned should be stored within your systems for reporting and reference information.

Contents

PostBackURL Fields

  • SMS Sent — This is posted when a message is sent from SMS Notify! to be delivered.
  • SMS Response — This is posted when a response to an outgoing message arrives.
  • SMS Received — This is posted when a message is sent to your DID and received by SMS Notify!
  • SMS Delivery Receipt — Delivery receipts are available for short code messaging only. Delivery receipts for DID messaging is currently unavailable. *If provided by recipient's carrier.

Set up a PostBackURL

Catch HTTP POSTs

Setup PostBackURL to catch HTTP POSTs from CDYNE
Example PostBackURLs: http://wiki.cdyne.com/index.php/SMS_Notify!_PostBackURLs#Capture_PostBackURL_Variables

Assign PostBackURL to DID/Short Code

When sending outgoing messages:

  1. Make sure the PostBack URL is assigned to DID/Short Code by contacting CDYNE, or
  2. Specify PostBackURL parameter with SimpleSMSSendWithPostback or AdvancedSMSSend when sending messages, or
  3. Assign a PostBackURL to your account DID or short code for automated SMS updates by logging into your account online.
    1. Select “Manage Services” on the left-hand menu
    2. Click open the SMS Notify! module
    3. Select “DID,” which will open a new screen listing your account DIDs or short codes
    4. Click on the edit button on the right and add the URL

Check API Responses for Error Codes

If the SMSError returns NoError, the message is successfully queued to be sent out.
If the SMSError returns with an error, fix accordingly.
At a minimum, store the SMS MessageID to associate with outgoing message.

Short Code Delivery Receipt Return Codes

View all possible return codes available with short code delivery receipts: http://wiki.cdyne.com/index.php/SMS_Delivery_Receipt

SMS Sent POST

PostBackURL will catch SMS Sent POST when CDYNE sends the message to the aggregator

Your application needs to ensure that SMSSent=1 for delivery to aggregator. If SMSSent=0, then aggregator wasn’t able to accept message. Most likely because destination phone number is a landline. If SMSSent=0, CDYNE will retry message automatically for a total of 3 times. If it fails 3 times, CDYNE will cancel message.

Auto Response via PostBackURL

When setting up an auto response via PostBackURL, CDYNE strongly recommends checking the post being received to avoid undesired messages from being sent. Look for the variable SMSResponse=1, which is posted when a response to an outgoing message arrives or when a MO message is sent to your DID.

Capture PostBackURL Variables

Use this code to read the information that is passed to your webpage from SMS Notify! Please note that data is posted to the headers. CDYNE recommends that the data returned to be stored within your systems for reporting and reference information.

C#

Example C# Code


//When CDYNE POSTs to this page, CDYNE has just received an incoming message (reply or MO), has just sent an outgoing message (MT), or CDYNE  
//has received a DR.
//Here we determine the type of Postback from CDYNE and call the appropriate method.
 
//If the POST contains SMSSent, CDYNE has just sent a message to an aggrigator
if (!String.IsNullOrEmpty(Request.Params["SMSSent"]))
{
//Capture POST
string SMSSent = Request.Params["SMSSent"];
string MessageID = Request.Params["MessageID"];
string ReferenceID = Request.Params["ReferenceID"];
string FromPhoneNumber = Request.Params["FromPhoneNumber"];
string ToPhoneNumber = Request.Params["ToPhoneNumber"];
string SentTime = Request.Params["SentTime"];
 
//Save/Store it
SomeMethodToSaveSent(Sent values);
}
 
//If the POST contains SMSResponse, it is an incoming message
if (!String.IsNullOrEmpty(Request.Params["SMSResponse"]))
{
//Capture POST
string SMSResponse = Request.Params["SMSResponse"];
string MessageID = Request.Params["MessageID"];
string MatchedMessageID = Request.Params["MatchedMessageID"];
string ReferenceID = Request.Params["ReferenceID"];
string FromPhoneNumber = Request.Params["FromPhoneNumber"];
string ToPhoneNumber = Request.Params["ToPhoneNumber"];
string ResponseReceiveDate = Request.Params["ResponseReceiveDate"];
string Message = Request.Params["Message"];
 
//Save/Store it
SomeMethodToSaveResponse(Response values);
}
 
//If the POST contains DeliveryReceipt, it is a Delivery Receipt
if (!String.IsNullOrEmpty(Request.Params["DeliveryReceipt"]))
{
//Capture POST
string DeliveryReceipt = Request.Params["DeliveryReceipt"];
string MessageID = Request.Params["MessageID"];
string ReferenceID = Request.Params["ReferenceID"];
string FromPhoneNumber = Request.Params["FromPhoneNumber"];
string ToPhoneNumber = Request.Params["ToPhoneNumber"];
string DeliveryReceiptMessage = Request.Params["DeliveryReceiptMessage"];
string Code = Request.Params["Code"];
 
//Save/Store it
SomeMethodToSaveDeliverReceipt(DeliveryReceipt values);
}

PHP

 
 
//Seperate logic for incoming and outgoing post types
//http://wiki.cdyne.com/index.php/SMS_Message_Sent_Postback
//http://wiki.cdyne.com/index.php/SMS_Message_Response_Postback
 
if($_POST['SMSSent'])
{
	//outgoing message has been queued for sending
 
	$smssent = $_POST['SMSSent'];
	$messageid = $_POST['MessageID'];
	$referenceid =	$_POST['ReferenceID'];
	$fromphonenumber = $_POST['FromPhoneNumber'];
	$tophonenumber = $_POST['ToPhoneNumber'];
	$senttime = $_POST['SentTime'];
 
	$sql = "insert into outgoingSMSTable values (".$smssent.",".$messageid.", ".$referenceid.", ".$fromphonenumber.", ".$tophonenumber.", ".$senttime.")";
 
	somedatabasecommandobject($sql);
 
 
}elseif ($_POST['SMSResponse']) {
 
        $smsresponse = $_POST['SMSResponse'];
	$messageid = $_POST['MessageID'];
	$matchedmessageid = $_POST['MatchedMessageID'];
	$referenceid = $_POST['ReferenceID'];
	$fromphonenumber = $_POST['FromPhoneNumber'];
	$tophonenumber = $_POST['ToPhoneNumber'];
	$responsereceivedate = $_POST['ResponseReceiveDate'];
	$message = $_POST['Message'];
 
	$sql = "insert into incomingSMSTable values (".$smsresposne.",".$messageid.", ".$matchedmessageid.", ".$referenceid.", ".$fromphonenumber.", ".$tophonenumber.", ".$responsereceivedate.", ".$message.")";
 
	somedatabasecommandobject($sql);
 
}
 
 
 

VB.NET

if(Request.Form["SMSSent"])
{
smssent = Request.Form["SMSSent"]
messageid = Request.Form["MessageID"]
referenceid = Request.Form["ReferenceID"]
fromphonenumber = Request.Form["FromPhoneNumber"]
tophonenumber = Request.Form["ToPhoneNumber"]
senttime = Request.Form["SentTime"]
 
sql = "insert into outgoingSMSTable values (".smssent.",".messageid.", ".referenceid.", ".fromphonenumber.", ".tophonenumber.", ".senttime.")"
 
somedatabasecommandobject(sql)
 
 
}elseif(Request.Form["SMSResponse"]){
 
smsresponse = Request.Form["SMSResponse"]
messageid = Request.Form["MessageID"]
matchedmessageid = Request.Form["MatchedMessageID"]
referenceid = Request.Form["ReferenceID"];
fromphonenumber = Request.Form["FromPhoneNumber"]
tophonenumber = Request.Form["ToPhoneNumber"];
responsereceivedate = Request.Form["ResponseReceiveDate"]
message = Request.Form["Message"]
 
sql = "insert into incomingSMSTable values (".smsresponse.",".messageid.", ".matchedmessageid.", ".referenceid.", ".fromphonenumber.", ".tophonenumber.", ".responsereceivedate.", ".message.")"
 
somedatabasecommandobject(sql)
 
}
Personal tools
Namespaces

Variants
Actions
Navigation
Tools

Trial Key