我正在使用 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,成就参数,POST
);如果我第二次调用 Graph API 返回 Bad Request 而不是 #3501 我可以删除获得的成就而不会出错(SendRequest(resultingURL, achievementParams, DELETE
);
我尝试使用不同的编码没有任何运气。这可能是 Graph API 中的错误吗?!(图形 API 资源管理器工作正常)
任何帮助将不胜感激