[英]The remote server returned an error: (400) Bad Request.
I am trying to make a facebook open graph api call from inside by web application.I am making a web request using a C# request like this. 我正试图通过Web应用程序从内部进行facebook打开图形api调用。我正在使用这样的C#请求发出Web请求。
string token = "q2Fe0utty5gzCasPL23...";
string url = "https://graph.facebook.com/me?access_token=" +
HttpUtility.UrlEncode(token) +"&response_type=id";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream receiveStream = response.GetResponseStream();
StreamReader readStream = newStreamReader(receiveStream,Encoding.UTF8);
string responseData = readStream.ReadToEnd();
_context.SaveChanges();
As the token has some special characters(+,/,==) in it i have encoded it using HttpUtility.UrlEncode(token) but still i get the following error. 由于令牌中有一些特殊字符(+,/,==),我使用HttpUtility.UrlEncode(令牌)对其进行编码,但仍然会出现以下错误。
The remote server returned an error: (400) Bad Request. 远程服务器返回错误:(400)错误请求。
How do i go about fixing this error. 我该如何解决此错误。 I did the above things by seeing some response in stack-overflow, but still getting the error.Where did i go wrong?
我通过在堆栈溢出中看到一些响应来做上述事情,但仍然得到错误。我哪里出错了?
As the token has some special characters(+,/,==)
因为令牌有一些特殊字符(+,/,==)
That sounds strange … usually access tokens consist of letters, numbers and maybe a pipe symbol. 这听起来很奇怪......通常访问令牌包括字母,数字和管道符号。
And if you make a request with a non-valid access token (not meaning expired, but a token that could not be decoded at all), then you'll get a 400 response. 如果您使用无效的访问令牌发出请求(不是意味着已过期,而是根本无法解码的令牌),那么您将获得400响应。
So please check your token in the debug tool, https://developers.facebook.com/tools/debug 因此,请在调试工具中检查您的令牌, https://developers.facebook.com/tools/debug
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.