When I send a request to https://graph.facebook.com/me/home?acces开发者_JAVA技巧s_token=(access code goes here) Facebook gives me this error message:
{
"error": {
"type": "OAuthException",
"message": "An unknown error has occurred."
}
}
Every other API call works. If anybody knows anything about this issue, please help me.
Facebook does not have very good error messages...
Apparantly, "An unknown error has occurred" means that I did not have valid permissions to access the user's news feed.
You have to include "read_stream" in your scope, or else facebook will reject your request with an ambiguous error message.
I <3 you facebook API
In addition to the other answers provided here...
In our production app (working with thousands of access tokens for several years), it appears that we occasionally get this error due to a temporary glitch in the API. I'm still not sure what the root cause is, but simply retrying the API call a few minutes later seems to consistently resolve the issue for us.
I get this error when the access token is the application's token. With the user-specific token, the api calls succeed.
Before the oauth upgrade, the application's token worked. The user-specific token worked and usually returned even more data.
Of course with facebook there's no way of knowing whether the current behavior (fails when using application token) is a bug or just the new way.
According to http://developers.facebook.com/docs/reference/api/, the parameter is access_token
, not access
.
I had this same issue and fixed it. For me, I was passing a single JSON object in the "batch" field, but Facebook wanted a JSON array.
For example, this will work, because it has a JSON array denoted by square brackets:
POST /v2.11 HTTP/1.1
Host: graph.facebook.com
Content-Type: application/json
Cache-Control: no-cache
{
"access_token":"YOUR_ACCESS_TOKEN",
"batch":[{"method":"GET", "relative_url":"me/friends?limit=50"}]
}
This will not, because there is no JSON array denoted by square brackets:
POST /v2.11 HTTP/1.1
Host: graph.facebook.com
Content-Type: application/json
Cache-Control: no-cache
{
"access_token":"YOUR_ACCESS_TOKEN",
"batch":{"method":"GET", "relative_url":"me/friends?limit=50"}
}
精彩评论