问题
I'm experiencing some problems getting an Open Graph implementation working.
As far as I can tell, I have the correct meta tags present. When I paste an URL into the Open Graph Debugger, it returns with the proper information defined (title, description, image, etc), and no errors.
I have version 3.1.1 of the Facebook PHP SDK.
I have Open Graph enabled for my development app, and I have an action (read
), and an object (article
) defined.
The implementation in question is a website, not a facebook application. On facebook, the app's "category" is "other". I followed some advice in another thread, and changed it to "Game", which did not work, so I have changed it back.
I authenticate my web app user with facebook and receive a code, which I then trade in for an access_token
, pretty standard. I ask for the following permissions:
publish_stream
publish_actions
offline_access
However, when I attempt to make a call to publish an action, I receive an OAuthException, and have no real way of debugging it.
Some oddities:
- The graph API doesn't seem to like the URL format specified in the documentation:
me/[app_namespace]:[action_type]
. In my case, this would beme/' . FB_APP_NAMESPACE . ':read
, where FB_APP_NAMESPACE is defined earlier to be a namespace as defined in the facebook application settings. Both the API and the Graph API Explorer throw an error stating that it doesn't understand the action given. It seems to be trying to read the namespace as the action. - If I remove the namespace from the url, it reports that the passed in action doesn't match the
og:type
defined in the url, since theog:type
in the url contains the same namespace I removed. - If I remove that namespace from the meta tag, and try again, I get a generic OAuthException that I can't debug.
- When I look at the code sample provided in my facebook app, the action seems to be
news.reads
instead of justread
. - If I use that action, the graph API returns an error saying that my ID is unauthorized to use the open graph, as it is not an admin, dev, or tester for my application. Unfortunately, I am the app creator, which means either the graph API is lying, or I am lying to myself!
I think the solution is pretty simple - perhaps I have forgotten something, or selected a certain category incorrect. Either way, this is a little frustrating, to say the least!
回答1:
Apparently, facebook's default read
call isn't available to use if your application/action isn't submitted.
I ended up creating my own read
action, and it worked on the first try. Go figure.
回答2:
For predefined actions the post url's are slightly different, you will have to use something like this:
POST https://graph.facebook.com/me/news.reads?article=[article object URL]
See: https://developers.facebook.com/docs/opengraph/actions/builtin/#read
来源:https://stackoverflow.com/questions/10366509/open-graph-calls-generating-oauth-exception