Difference between revisions of "SMS Notify! PostBackURLs"

From CDYNE Wiki
Jump to navigation Jump to search
(4 intermediate revisions by the same user not shown)
Line 128: Line 128:
$senttime = $_POST['SentTime'];
$senttime = $_POST['SentTime'];
$sql = "insert into outgoingSMSTable values (".$smssent.",".$messageid.", ".$referenceid.", ".$fromphonenumber.", ".$tophonenumber.", ".$senttime.")";
$savedfile = "saving values (".$smssent.",".$messageid.", ".$referenceid.", ".$fromphonenumber.", ".$tophonenumber.", ".$senttime.")";
Some method to save values($savedfile);
Line 144: Line 144:
$message = $_POST['Message'];
$message = $_POST['Message'];
$sql = "insert into incomingSMSTable values (".$smsresposne.",".$messageid.", ".$matchedmessageid.", ".$referenceid.", ".$fromphonenumber.", ".$tophonenumber.", ".$responsereceivedate.", ".$message.")";
$savedfile = "saving values (".$smsresposne.",".$messageid.", ".$matchedmessageid.", ".$referenceid.", ".$fromphonenumber.", ".$tophonenumber.", ".$responsereceivedate.", ".$message.")";
Some method to save values($savedfile);
Line 166: Line 166:
senttime = Request.Form["SentTime"]
senttime = Request.Form["SentTime"]
sql = "insert into outgoingSMSTable values (".smssent.",".messageid.", ".referenceid.", ".fromphonenumber.", ".tophonenumber.", ".senttime.")"
$savedfile = "saving values (".smssent.",".messageid.", ".referenceid.", ".fromphonenumber.", ".tophonenumber.", ".senttime.")"
some method to save values($savedfile)
Line 182: Line 182:
message = Request.Form["Message"]
message = Request.Form["Message"]
sql = "insert into incomingSMSTable values (".smsresponse.",".messageid.", ".matchedmessageid.", ".referenceid.", ".fromphonenumber.", ".tophonenumber.", ".responsereceivedate.", ".message.")"
$savedfile = "saving values (".smsresponse.",".messageid.", ".matchedmessageid.", ".referenceid.", ".fromphonenumber.", ".tophonenumber.", ".responsereceivedate.", ".message.")"
some method to save values($savedfile)

Latest revision as of 15:46, 12 September 2019

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.

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


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


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.


Example C# Code

 1 //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  
 2 //has received a DR.
 3             //Here we determine the type of Postback from CDYNE and call the appropriate method.
 5             //If the POST contains SMSSent, CDYNE has just sent a message to an aggrigator 
 6             if (!String.IsNullOrEmpty(Request.Params["SMSSent"]))
 7             {
 8                 //Capture POST
 9                 string SMSSent = Request.Params["SMSSent"];
10                 string MessageID = Request.Params["MessageID"];
11                 string ReferenceID = Request.Params["ReferenceID"];
12                 string FromPhoneNumber = Request.Params["FromPhoneNumber"];
13                 string ToPhoneNumber = Request.Params["ToPhoneNumber"];
14                 string SentTime = Request.Params["SentTime"];
16                 //Save/Store it
17                 SomeMethodToSaveSent(Sent values);
18             }
20             //If the POST contains SMSResponse, it is an incoming message
21             if (!String.IsNullOrEmpty(Request.Params["SMSResponse"]))
22             {
23                 //Capture POST
24                 string SMSResponse = Request.Params["SMSResponse"];
25                 string MessageID = Request.Params["MessageID"];
26                 string MatchedMessageID = Request.Params["MatchedMessageID"];
27                 string ReferenceID = Request.Params["ReferenceID"];
28                 string FromPhoneNumber = Request.Params["FromPhoneNumber"];
29                 string ToPhoneNumber = Request.Params["ToPhoneNumber"];
30                 string ResponseReceiveDate = Request.Params["ResponseReceiveDate"];
31                 string Message = Request.Params["Message"];
33                 //Save/Store it
34                 SomeMethodToSaveResponse(Response values);            
35             }
37             //If the POST contains DeliveryReceipt, it is a Delivery Receipt
38             if (!String.IsNullOrEmpty(Request.Params["DeliveryReceipt"]))
39             {
40                 //Capture POST
41                 string DeliveryReceipt = Request.Params["DeliveryReceipt"];
42                 string MessageID = Request.Params["MessageID"];
43                 string ReferenceID = Request.Params["ReferenceID"];
44                 string FromPhoneNumber = Request.Params["FromPhoneNumber"];
45                 string ToPhoneNumber = Request.Params["ToPhoneNumber"];
46                 string DeliveryReceiptMessage = Request.Params["DeliveryReceiptMessage"];
47                 string Code = Request.Params["Code"];
49                 //Save/Store it
50                 SomeMethodToSaveDeliverReceipt(DeliveryReceipt values);            
51             }


 1 //Seperate logic for incoming and outgoing post types
 2 //http://wiki.cdyne.com/index.php/SMS_Message_Sent_Postback
 3 //http://wiki.cdyne.com/index.php/SMS_Message_Response_Postback
 5 if($_POST['SMSSent'])
 6 {
 7 	//outgoing message has been queued for sending
 9 	$smssent = $_POST['SMSSent'];
10 	$messageid = $_POST['MessageID'];
11 	$referenceid =	$_POST['ReferenceID'];
12 	$fromphonenumber = $_POST['FromPhoneNumber'];
13 	$tophonenumber = $_POST['ToPhoneNumber'];
14 	$senttime = $_POST['SentTime'];
16 	$savedfile = "saving values (".$smssent.",".$messageid.", ".$referenceid.", ".$fromphonenumber.", ".$tophonenumber.", ".$senttime.")";
18 	Some method to save values($savedfile);
21 }elseif ($_POST['SMSResponse']) {
23         $smsresponse = $_POST['SMSResponse'];
24 	$messageid = $_POST['MessageID'];
25 	$matchedmessageid = $_POST['MatchedMessageID'];
26 	$referenceid = $_POST['ReferenceID'];
27 	$fromphonenumber = $_POST['FromPhoneNumber'];
28 	$tophonenumber = $_POST['ToPhoneNumber'];
29 	$responsereceivedate = $_POST['ResponseReceiveDate'];
30 	$message = $_POST['Message'];
32 	$savedfile = "saving values (".$smsresposne.",".$messageid.", ".$matchedmessageid.", ".$referenceid.", ".$fromphonenumber.", ".$tophonenumber.", ".$responsereceivedate.", ".$message.")";
34 	Some method to save values($savedfile);
36 }


 1 if(Request.Form["SMSSent"])
 2 {
 3 	smssent = Request.Form["SMSSent"]
 4 	messageid = Request.Form["MessageID"]
 5 	referenceid =	Request.Form["ReferenceID"]
 6 	fromphonenumber = Request.Form["FromPhoneNumber"]
 7 	tophonenumber = Request.Form["ToPhoneNumber"]
 8 	senttime = Request.Form["SentTime"]
10 	$savedfile = "saving values (".smssent.",".messageid.", ".referenceid.", ".fromphonenumber.", ".tophonenumber.", ".senttime.")"
12 	some method to save values($savedfile)
15 }elseif(Request.Form["SMSResponse"]){
17         smsresponse = Request.Form["SMSResponse"]
18 	messageid = Request.Form["MessageID"]
19 	matchedmessageid = Request.Form["MatchedMessageID"]
20 	referenceid = Request.Form["ReferenceID"];
21 	fromphonenumber = Request.Form["FromPhoneNumber"]
22 	tophonenumber = Request.Form["ToPhoneNumber"];
23 	responsereceivedate = Request.Form["ResponseReceiveDate"]
24 	message = Request.Form["Message"]
26 	$savedfile = "saving values  (".smsresponse.",".messageid.", ".matchedmessageid.", ".referenceid.", ".fromphonenumber.", ".tophonenumber.", ".responsereceivedate.", ".message.")"
28 	some method to save values($savedfile)
30 }