有懂淘宝平台主动业务推送的吗?求指教

cobra009 2011-09-30 11:21:19
我现在在做主动消息通知这一块

TopDictionary txtParams = new TopDictionary();
txtParams.Add("app_key", appkey);
txtParams.Add("timestamp", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://stream.api.taobao.com/stream");
string sign = TopUtils.SignTopRequest(txtParams, appsecret, true);
req.ContentType = "application/x-www-form-urlencoded; charset=utf-8";
req.Method = "POST";
string param = "app_key=" + appkey + "&sign=" + sign.ToUpper() + "×tamp=" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
byte[] bs = Encoding.UTF8.GetBytes(param);
req.ContentLength = bs.Length;
Stream reqStream = req.GetRequestStream();
reqStream.Write(bs, 0, bs.Length);
HttpWebResponse wr;
try
{
wr = (HttpWebResponse)req.GetResponse();
Console.WriteLine(wr.StatusCode.ToString());
StreamReader str = new StreamReader(wr.GetResponseStream(), Encoding.UTF8);

//IncrementCustomerPermitRequest inc = new IncrementCustomerPermitRequest();
//IncrementCustomerPermitResponse increq = client.Execute(inc, Session["sessionKey"].ToString());

}
catch (Exception ex)
{
Response.Write(ex.Message);
}


总是被CATCH到远程服务器返回错误: (400) 错误的请求。
具体是在wr = (HttpWebResponse)req.GetResponse();被CATCH的
代码在淘宝平台被确认是正确的,别人能够连接,可能是我的操作步骤有问题,谁有具体的步骤啊?
...全文
276 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
flashrhx2010 2012-02-04
  • 打赏
  • 举报
回复
你缺少一个ID参数,多看看淘宝帮助吧
flashrhx2010 2012-02-04
  • 打赏
  • 举报
回复
你缺少一个ID参数,多看看淘宝帮助吧
nbgcqlk 2011-09-30
  • 打赏
  • 举报
回复
步骤没错。淘宝那边有没有错误的详细解释??例如sign验证没通过?或者一次最多传输数据量的限制。。。。。帮顶了。。。
cobra009 2011-09-30
  • 打赏
  • 举报
回复
在线等,急用啊!~~

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧