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.
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>
Related
I have a web app running on a local server that I can log into Facebook through.
I have been trying to add or delete comments from Posts are made by me and on my timeline.
When I try to execute the FB.api() call I get a failed response saying that I need a Page Access Token. The thing is, I've been looking around a lot and have seen nowhere a mention of a Page Access Token for a specific Persons profile.
Through experimenting I've been able to:
Get a Page Access Token for a non-profile Page that I own
Add/Delete Comments/Posts on that non-profile page
Add/Delete Posts made by the app on my profile
Display all Posts/Comments on my profile
What I want to do:
Be able to delete/add comments on Posts on MY profile
What I've tried:
GET request for {my-id}?field=access_token. I figured that if it worked for a non-profile page, it would work for my profile. It didn't work.
A lot of googling
My Assumptions:
I need a Page Access Token for my own profile if I want to add/delete things that were not made by the app
A Page Acess Token for a profile exists.
Below is an example of a FB.api call that would return a response saying:
"Publishing comments through the API is only available for page access tokens"
FB.api(`${comment_id}`, 'DELETE', function(response) {
console.log(response);
});
I really just need someone to give me some concrete answers.
I have an application and am trying to connect with:
FB.login(statusChangeAfterLogin,
{ scope:"public_profile,email,user_friends,publish_actions" });
However, it looks like the publish_actions gets totally ignored.
That is, our application is able to get the public profile information, the email, and user friend list, but it is not able to share a dynamically generate image.
I tried to break the login in two steps as in:
// first login when initializing (no publish_actions)
FB.login(statusChangeAfterLogin,
{ scope:"public_profile,email,user_friends" });
// second login when user is ready to share (just publish_actions)
FB.login(statusChangeAfterLogin,
{ scope:"publish_actions" });
However, it looks like the second action does absolutely nothing.
I'm not able to understand why I am supposed to do to allow the sharing without first having the publish_actions in the scope. I can see that it appears in the list of GET variables and includes all the parameters as expected, but the second login just opens a popup, close it, and done.
All the other permissions donĀ“t need review, but publish_actions does. I assume you are not trying as a user with a role in the App. Read about Login Review: https://developers.facebook.com/docs/facebook-login/review
publish_actions only works for users with a role in the App, you need to go through the review process in order to make it available for everyone else.
I want to get my Facebook news feed in order to filter depending on some options.
But when I ask for permission as below, read_stream is not accepted, I 'm getting "Invalid Scopes: read_stream"
FB.login(checkLoginStatus, {scope:'read_stream,email,publish_actions, user_friends, user_posts '});
Looking around in Internet, I found out that this permission has to be required from Facebook.
Any workaround for that would be much appreciated.
The permission read_stream was deprecated with v2.4. You wouldn't have gotten it granted during Login Review anyway.
Basically, /{user_id}/home endpoint with the newsfeed is no longer accessible. If you want to use /{user_id}/feed, that should work, but this only contains the user's own timeline.
See
https://developers.facebook.com/docs/apps/changelog#v2_4
https://developers.facebook.com/docs/graph-api/reference/v2.4/user/home/
https://developers.facebook.com/docs/graph-api/reference/v2.4/user/feed
I cannot find any example on facebook dev. or here on stackoverflow so I need to make this post which i didn't thought i had to.
I have a website which uses the facebook JavaScript SDK to login users into it.
When I log in users I uses the
FB.login(), scope:{'email, offline_access'}
When the login in done i get the short lived access token and passes it to:
https://graph.facebook.com/oauth/access_token?
grant_type=fb_exchange_token&
client_id=APP_ID&
client_secret=APP_SECRET&
fb_exchange_token=SHORT_LIVED_ACCESS_TOKEN
So i get the long lived, 60day, token in response. This is done server-side and i save the new long lasting token in my database along with facebook id etc.
Now to my problem. Every day at a certain time I want to update the users data in my database using the access token, which i have read that could. But how do i do that?
I'm used to do like this after the FB.login() but now when the user do not login I don't know how to do the call to FB.api using my persisted token?
FB.api(/me....)
Regards,
Kristoffer
As you have to synchronize/update information when user is not logged in you will have to use server side interaction.
You may use your saved Extended Access Token and set it into Facebook PHP SDK using setAccessToken() method.
$facebook->setAccessToken($extended_access_token);
After this you may call $facebook->api(...) method to perform the task that you intend to.
What started off as easy as "Let's put all our brand's Facebook posts on our website" has turned out much more difficult.
The situation:
There are multiple admins that manage the Facebook fan page (20+)
RSS feeds no longer seem to work with some brand pages
I have registered an APP ID, and am getting back an access token at an application level like so:
https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=AAAAAAAA&client_secret=BBBBBBBB;
Below are some varying cases and what they return. All examples below assume the access token is retrieved using the URL above
Case 1: /posts
Will return the wall posts of the parent account (the one who started the Facebook fan page), and not the admin's who administer it.
https://graph.facebook.com/PAGE_NAME/posts?access_token=XXXXXXXXXX;
Case 2: /feed
Will return the wall posts by all other users, and NOT the admins or page owners
https://graph.facebook.com/PAGE_NAME/feed?access_token=XXXXXXXXXX;
Case 3: FQL
Will return same results as Case 1, note DDDDDDD = Page UID
SELECT post_id, created_time, message FROM stream WHERE source_id=DDDDDDDD AND actor_id=DDDDDDDD
Now, funnily enough, when I use Facebook's Graph API Explorer (logged in of course), and I call Case 1 above "/posts" I DO get all the posts (including the ones from all page admins and owners). This is exactly what I want!
So why am I here? Because of the access token issue. This is a stream to be used on a website, i.e. there is no requirement for a user to connect to Facebook as we don't need their permissions nor to access their data, which is why I'm using the application access token.
Is manage_pages permission given to your app token? I hope this link helps: http://developers.facebook.com/docs/authentication/pages/