gpt4 book ai didi

quickblox - 如何在 Quickblox 中获取代币?

转载 作者:行者123 更新时间:2023-12-02 22:19:08 28 4
gpt4 key购买 nike

我在我的 C# (Xamarin) 应用程序中使用 Quickblox。我无法移植 Windows Phone 代码,因此我决定使用 RESTful API。

我在获取 token 时遇到问题。我关注了this tutorial这是我的代码:

public string Timestamp()
{
long ticks = DateTime.UtcNow.Ticks - DateTime.Parse("01/01/1970 00:00:00").Ticks;
ticks /= 10000000;
return ticks.ToString();
}

public string GetToken()
{
HttpWebRequest httpWReq = (HttpWebRequest)WebRequest.Create("https://api.quickblox.com/session.xml");

string application_id = "2675";
string auth_key = "rGvHTKPyJJQ8PFR";
string timestamp = Timestamp ();
string auth_secret = "wePb4NG74eZT3eK";

ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "application_id=" + application_id;
postData += "&auth_key=" + auth_key;
postData += "&timestamp=" + timestamp;

string signature = Hash (auth_secret, postData);
postData += "&signature=" + signature;
byte[] data = encoding.GetBytes(postData);

httpWReq.Method = "POST";
httpWReq.ContentType = "application/x-www-form-urlencoded";
httpWReq.ContentLength = data.Length;
httpWReq.Headers ["QuickBlox-REST-API-Version"] = "0.1.0";

using (Stream stream = httpWReq.GetRequestStream())
{
stream.Write(data,0,data.Length);
}

HttpWebResponse response = (HttpWebResponse)httpWReq.GetResponse();

string responseString = new StreamReader (response.GetResponseStream()).ReadToEnd ();
return responseString;
}

在结果中,我在尝试接收httpWReq.GetResponse()时收到异常“422:无法处理的实体”

最佳答案

您忘记添加nonce参数。

此外,您应该在生成签名时使用它

关于quickblox - 如何在 Quickblox 中获取代币?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16696477/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com