Impementing Clickatell CallBack in ASP.NET using C#.NET
NickName:Walter Lockhart Ask DateTime:2010-02-04T04:31:25

Impementing Clickatell CallBack in ASP.NET using C#.NET

I am building a web application in ASP.NET using C#.NET which sends a SMS using clickatell.

I am trying unsuccessfully to receive a status back from clickatell by creating a CallBack Page called ClickatellCallBack.aspx Here is the codebehind of the Page:

public partial class ClickatellCallBack : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Retrieve the values from the QueryString.
string apiID = Request.QueryString["api_id"];
string from = Request.QueryString["from"];
string to = Request.QueryString["to"];
string timestamp = Request.QueryString["timestamp"];
string apiMsgId = Request.QueryString["apiMsgId"];
string cliMsgId = Request.QueryString["cliMsgId"];
string status = Request.QueryString["status"];
string charge = Request.QueryString["charge"];

   // Insert the SMS Status values into the database.  
   int smsStatusID = SMSManager.InsertSMSStatus(apiID, from, to,
      timestamp, apiMsgId, cliMsgId, status, charge);  

}
}

Basically, this Page retrieves the Query String values sent from clickatell and inserts them into a database table.

I have registered the following Callback URL: http://www.mydomain.com/ClickatellCallBack.aspx with clickatell and selected the Callback Type: HTTP GET

In my 'sendmsg' command I set delivery acknowledgement and callback request as follows: deliv_ack=1 and callback=3

The only problem being that nothing appears to be happening. The CallBack URL doesn't appear to be reached by clickatell.

Am I missing something? Am I doing something wrong. Do I need to implement this Callback URL using something other than an ASP.NET Page? Is there some clickatell setting I'm missing?

Any help would be greatly appreciated.

Regards

Walter

Copyright Notice:Content Author:「Walter Lockhart」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/2195200/impementing-clickatell-callback-in-asp-net-using-c-net

Answers
Walter Lockhart 2010-02-09T11:18:14

I solved the problem by placing the callback and deliver_ack parameters with the startbatch command and not the quicksend command. This seems to work. So here is what I have inside the C#.NET function that starts the batch:\n\nprotected string get_batch_id(string session_id, string message_body)\n{\n // Declare a WebClient.\n WebClient client = new WebClient();\n\n // Add a User Agent Header.\n client.Headers.Add(\"user-agent\", \"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR1.0.3705;)\");\n\n // Add the session_id to the Query String.\n client.QueryString.Add(\"session_id\", session_id);\n\n // Add the template to the Query String.\n client.QueryString.Add(\"template\", message_body);\n\n // Add the callback to the Query String.\n client.QueryString.Add(\"callback\", \"3\");\n\n // Add the deliv_ack to the Query String.\n client.QueryString.Add(\"deliv_ack\", \"1\");\n\n // Declare the baseurl.\n string baseurl = \"http://api.clickatell.com/http_batch/startbatch\";\n\n // Open the baseurl.\n Stream data = client.OpenRead(baseurl);\n\n // Declare and instantiate a StreamReader to retrieve the results of executing the startbatch command.\n StreamReader reader = new StreamReader(data);\n\n // Parse and split the returned string into the returned_strings array.\n string[] returned_strings = reader.ReadToEnd().Split(' ');\n\n // Retrieve the batch_id from the (second element of the) returned_strings array.\n string batch_id = returned_strings[1].ToString();\n\n // Close the Stream.\n data.Close();\n\n // Close the Reader.\n reader.Close();\n\n // Return the batch_id.\n return (batch_id);\n}\n\n\nPhew!\n\nSo I've also managed to get the following functionality successfully coded up in ASP.NET using C#.NET:\n\n\nSend a message to a single recipient;\nSend the same message to multiple recipients;\nSend a personalised message to a single recipient;\nSend a personalised message to multiple recipients;\n\n\nAlong the way I've noticed that there aren't too many cliackatell code samples in ASP.NET using C#.NET.",


More about “Impementing Clickatell CallBack in ASP.NET using C#.NET” related questions

Impementing Clickatell CallBack in ASP.NET using C#.NET

I am building a web application in ASP.NET using C#.NET which sends a SMS using clickatell. I am trying unsuccessfully to receive a status back from clickatell by creating a CallBack Page called

Show Detail

Clickatell callback url to receive messages not working

I have a clickatell account and i am trying to receive messages in php using it. I understand that I need to setup a callback url on it and i have added that. In the callback url, i have added the

Show Detail

sending multiple messages using clickatell gateway

I used php server side to connect with clickatell messages service , i used the soap api technique to make the connection . it is working .but in my code , i can send just one message at the same t...

Show Detail

Sending SMS using clickatell in ASP.Net

I have tried this code from their site using System.Net; using System.IO; WebClient client = new WebClient(); // Add a user agent header in case the requested URI contains a query. client.Headers....

Show Detail

Phone Number verification using Clickatell?

I have developed a Web API in .net 6.0 which is using Clickatell Rest based API's and it works fine also receiving the request & getting a response back from an api, but Clickatell API is not l...

Show Detail

MissingPropertyException on Clickatell API in grails

I am working on a Web App on grails and I am using Clickatell as the Web API. I have these codes on an SMSNotifier.groovy class. Yet, I encounter the MissingPropertyException groovy.lang.

Show Detail

Clickatell One API Customer Call Back not returning anything

I have developed a call back REST service using the following link as reference https://docs.clickatell.com/channels/one-api/one-api-reference/#tag/One-API-Client-Callbacks/operation/

Show Detail

How can I catch the information of a callback?

The code i am using to send messages works fine. I have configured the web-hooks correctly as the clickatell server is giving a 200 response which means my system received the callback but it is not

Show Detail

Trouble installing Clickatell Php Library

I'm trying to install the clickatell php library after this instruction: https://github.com/arcturial/clickatell But so far i was only able to install composer. They say: this library uses compo...

Show Detail

Clickatell - Whatsapp integration

I'm trying to send a test message using Whatsapp and I'm getting this error message: "error":{"code":27,"description":"Recipient not available on channel."} I did find the error message h

Show Detail