使用C#.NET Impementing的Clickate回调ASP.NET [英] Impementing Clickatell CallBack in ASP.NET using C#.NET

查看:189
本文介绍了使用C#.NET Impementing的Clickate回调ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用ASP.NET使用的Clickate它发送短信C#.NET构建Web应用程序。

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

我想不成功通过创建名为ClickatellCallBack.aspx这里的回调页接收状态,从后面的Clickate是页面的codebehind:

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:

公共部分类ClickatellCallBack:System.Web.UI.Page结果
  {结果
  保护无效的Page_Load(对象发件人,EventArgs的)结果
     {结果
         //检索查询字符串的值。结果
         字符串apiID =的Request.QueryString [api_id];结果
         从=的Request.QueryString [从]字符串;结果
         字符串=的Request.QueryString [到];结果
         串时间戳=的Request.QueryString [时间戳];结果
         字符串apiMsgId =的Request.QueryString [apiMsgId];结果
         字符串cliMsgId =的Request.QueryString [cliMsgId];结果
         字符串状态=的Request.QueryString [状态];结果
         字符串费=的Request.QueryString [充电];

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);  


  
  

}结果
  }

}
}

基本上,这个页面检索的Clickate发送的查询字符串值,并将其插入到数据库表。

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

我已经注册了以下回调网址: http://www.mydomain.com/ClickatellCallBack.aspx 用的Clickate并选择了回调类型:HTTP GET

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

在我的SENDMSG'命令我设置交货确认和回调的要求如下:deliv_ack = 1和回调= 3

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

唯一的问题是,没有什么似乎发生。回调URL似乎并不受的Clickate到达。

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

我缺少的东西吗?我是不是做错了什么。我是否需要使用比ASP.NET页面以外的东西来实现这个回调网址?有一些的Clickate设置我失踪?

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?

任何帮助将大大AP preciated。

Any help would be greatly appreciated.

问候

沃尔特

推荐答案

我通过将回调deliver_ack参数与startbatch命令,而不是quicksend命令解决了这个问题。这似乎工作。因此,这里是什么我有启动批量的 C#.NET 函数中:

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:

protected string get_batch_id(string session_id, string message_body)
{
    // Declare a WebClient.
    WebClient client = new WebClient();

    // Add a User Agent Header.
    client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR1.0.3705;)");

    // Add the session_id to the Query String.
    client.QueryString.Add("session_id", session_id);

    // Add the template to the Query String.
    client.QueryString.Add("template", message_body);

    // Add the callback to the Query String.
    client.QueryString.Add("callback", "3");

    // Add the deliv_ack to the Query String.
    client.QueryString.Add("deliv_ack", "1");

    // Declare the baseurl.
    string baseurl = "http://api.clickatell.com/http_batch/startbatch";

    // Open the baseurl.
    Stream data = client.OpenRead(baseurl);

    // Declare and instantiate a StreamReader to retrieve the results of executing the startbatch command.
    StreamReader reader = new StreamReader(data);

    // Parse and split the returned string into the returned_strings array.
    string[] returned_strings = reader.ReadToEnd().Split(' ');

    // Retrieve the batch_id from the (second element of the) returned_strings array.
    string batch_id = returned_strings[1].ToString();

    // Close the Stream.
    data.Close();

    // Close the Reader.
    reader.Close();

    // Return the batch_id.
    return (batch_id);
}

唷!

所以我也设法得到了以下功能成功地使用美元,ASP.NET C $ CD了 C#.NET

So I've also managed to get the following functionality successfully coded up in ASP.NET using C#.NET:


  1. 将消息发送到一个收件人;

  2. 发送同样的消息给多个收件人;

  3. 发送个性化的信息给一个收件人;

  4. 发送个性化的信息给多个收件人;

一路上我注意到,有没有在 ASP.NET 使用过多的cliackatell code样本 C#.NET

Along the way I've noticed that there aren't too many cliackatell code samples in ASP.NET using C#.NET.

这篇关于使用C#.NET Impementing的Clickate回调ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆