|
地板
楼主 |
发表于 2016-2-19 17:25:53
|
只看该作者
long n_timestamp = DateTimeToUnixTimestamp(DateTime.Now); //获取时间戳
string n_signature = GetMd5Hash("af63185f68fb4f2fa6ca0c1781b979b7" + n_timestamp.ToString()).ToLower();//加密
var data = new {
product_key = "7de3063398ad4a889b7b30d97e907798",
mac = "5CCF7F83172D",
remark = "dd",
dev_alias = "dddd"
};
SerializerHelper serializerHelper = new SerializerHelper();
var jsonString = serializerHelper.GetJsonString(data, null);
using (MemoryStream ms = new MemoryStream())
{
var bytes = Encoding.UTF8.GetBytes(jsonString);
// await ms.WriteAsync(bytes, 0, bytes.Length);
ms.Write(bytes, 0, bytes.Length);
ms.Seek(0, SeekOrigin.Begin);
WebHeaderCollection nheader = new WebHeaderCollection();
nheader["X-Gizwits-Application-Id"] = "c5cd9be8f7d5462fbaff70956bfe0662";
nheader["X-Gizwits-User-token"] = str_tocken;
nheader["X-Gizwits-Timestamp"] = n_timestamp.ToString();
nheader["X-Gizwits-Signature"] = n_signature;
try
{
resopdata ddd = Post.PostGetJsonjz<resopdata>("http://api.gizwits.com/app/bind_mac", null, ms, null, nheader, timeOut: 100000);
MessageBox.Show(ddd.token);
}
catch (WebException ex)
{
MessageBox.Show(ex.Response.ToString());
disslogin();
}
}
异常扑获,远程服务错误400,的 token 是从匿名登陆那个接口获取的 都不知道问题出在那,其它接口都调用成功,证明格式是没有问题的,请大侠指点一下,
|
|