Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Explain the Facebook access_token

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.

like image 850
powerbuoy Avatar asked Nov 05 '22 02:11

powerbuoy


1 Answers

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>
like image 143
Jashwant Avatar answered Nov 09 '22 07:11

Jashwant