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.
Setup PostBackURL to catch HTTP POSTs from CDYNE
Example PostBackURLs:
http://wiki.cdyne.com/SMS_Notify!_PostBackURLs#Capture_PostBackURL_Variables
When sending outgoing messages:
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.
View all possible return codes available with short code delivery
receipts: http://wiki.cdyne.com/SMS_Delivery_Receipt
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.
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.
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.
//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);
}
//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'];
$savedfile = "saving values (".$smssent.",".$messageid.", ".$referenceid.", ".$fromphonenumber.", ".$tophonenumber.", ".$senttime.")";
Some method to save values($savedfile);
}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'];
$savedfile = "saving values (".$smsresposne.",".$messageid.", ".$matchedmessageid.", ".$referenceid.", ".$fromphonenumber.", ".$tophonenumber.", ".$responsereceivedate.", ".$message.")";
Some method to save values($savedfile);
}
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"]
$savedfile = "saving values (".smssent.",".messageid.", ".referenceid.", ".fromphonenumber.", ".tophonenumber.", ".senttime.")"
some method to save values($savedfile)
}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"]
$savedfile = "saving values (".smsresponse.",".messageid.", ".matchedmessageid.", ".referenceid.", ".fromphonenumber.", ".tophonenumber.", ".responsereceivedate.", ".message.")"
some method to save values($savedfile)
}