带有“错误请求 - 协议错误”的图形 API 响应关于获得的成就而不是#3501
我使用 C# 和 ASP.NET 来制作游戏。我有一种发送帖子请求的方法,并且它在所有请求(即日志记录、分数)中都工作正常,除了当我尝试提供获得的成就时。在这种情况下,服务器返回错误请求(状态 - 协议错误)而不是 (#3501) 用户已经赢得了...... 这是我的发送方法的一个片段
public static string SendRequest(string sUrl,
string sRequest,
string sMethod,
string sContentType = "application/x-www-form-urlencoded")
{
HttpWebRequest request;
StreamReader reader;
string sResponse;
Encoding encoding = Encoding.UTF8; //I try different encoding without luck
switch (sMethod.ToUpper())
{
case "POST":
case "DELETE":
//Initialize the WebRequest
request = (HttpWebRequest)HttpWebRequest.Create(sUrl);
request.AllowAutoRedirect = false;
request.Method = sMethod.ToUpper();
request.ContentType = sContentType;
request.ServicePoint.Expect100Continue = false;
byte[] data = encoding.GetBytes(sRequest);
request.ContentLength = data.Length;
Stream stream =request.GetRequestStream();
stream.Write( data, 0, data.Length );
stream.Close();
break;
......
因此,为了获得新的成就,我调用此方法: SendRequest(成就URL,成就Params,POST
); 如果我第二次调用 Graph API 将返回错误请求而不是 #3501 我可以毫无错误地删除获得的成就( SendRequest( AchievementURL, AchievementParams, DELETE
);
我尝试使用不同的编码,但没有任何运气。这可能是 Graph API 中的错误吗?!( Graph API Explorer 工作正常)
任何帮助将不胜感激
I'm using C# with ASP.NET to make a game. I have a method to send post request and it's working fine in all request ( i.e. loging, scores ) exept when I try to give an earned achievement. In this case the server return Bad Request ( status - protocol error ) instead of (#3501) User has already earned ....
This is a snipped from my method for sending
public static string SendRequest(string sUrl,
string sRequest,
string sMethod,
string sContentType = "application/x-www-form-urlencoded")
{
HttpWebRequest request;
StreamReader reader;
string sResponse;
Encoding encoding = Encoding.UTF8; //I try different encoding without luck
switch (sMethod.ToUpper())
{
case "POST":
case "DELETE":
//Initialize the WebRequest
request = (HttpWebRequest)HttpWebRequest.Create(sUrl);
request.AllowAutoRedirect = false;
request.Method = sMethod.ToUpper();
request.ContentType = sContentType;
request.ServicePoint.Expect100Continue = false;
byte[] data = encoding.GetBytes(sRequest);
request.ContentLength = data.Length;
Stream stream =request.GetRequestStream();
stream.Write( data, 0, data.Length );
stream.Close();
break;
....
So to give an new achievement I call this method:
SendRequest( achievementURL, achievementParams, POST
);
If I make second call Graph API return Bad Request instead of #3501
I can delete earned achievement without error ( SendRequest( achievementURL, achievementParams, DELETE
);
I try to use different encodings without any luck. Can it be a bug in Graph API?! ( Graph API Explorer works fine )
Any help will be appreciateble
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“我尝试使用不同的编码,但没有任何运气。这可能是 Graph API 中的错误吗?!(Graph API Explorer 工作正常)”
是的,我遇到了类似的问题,C# SDK 返回了错误而 API Explorer 工作正常。当我等待修复时,我正在使用 Javascript SDK 进行 C# 中失败的调用。
您应该将其记录为错误 http://facebooksdk.codeplex.com/workitem/list/basic
"I try to use different encodings without any luck. Can it be a bug in Graph API?! ( Graph API Explorer works fine )"
Yeah, I encountered a similar issue where the C# SDK returned an error while the API Explorer worked fine. While I wait for a fix, I'm using the Javascript SDK to make the call that fails in C#.
You should log it as a bug at http://facebooksdk.codeplex.com/workitem/list/basic