Explain the Facebook access_token

混江龙づ霸主 提交于 2019-11-30 17:29:42

问题


This whole Facebook access_token thing is driving me nuts. All I want to do is fetch a user's public Facebook posts.

It used to work by simply doing:

$.getJSON('http://graph.facebook.com/USERNAME/posts?limit=LIMIT&callback=?', function (posts) {
    // Posts available in "posts" variable
});

But now I get the "access_token required" error.

Trust me; I've checked the docs, Googled all over and checked similar questions on SO but I'm really hoping there's a more straight forward way of doing this than what I've seen.

Do you really have to create a Facebook App (I don't even have an account), make the user "accept" the app and login etc for this to work?

With Twitter it's just as easy as it used to be with Facebook.


回答1:


You really have to create a Facebook App (You need to have an account), make the user "accept" the app and login etc for this to work.

However you can search public posts of user (not a specific user) by facebook's public search api.

e.g.

https://graph.facebook.com/search?q=hello&type=post

This will search all posts with hello keyword in it.

Reference ( you need to have facebook account to see this page )

http://developers.facebook.com/docs/reference/api/

Edit (after seeing comments):

If you want to access public posts of your own page. You can pull it without any login from user (but you will need an access_token)

Generate an offline access_token from here,

http://developers.facebook.com/tools/explorer.

Then you can use that token to pull data . Thus no need of logging on by user.

https://graph.facebook.com/wesellwine/posts?access_token=<access_token from graph api explorer>


来源:https://stackoverflow.com/questions/9970381/explain-the-facebook-access-token

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!