Facebook page access token doesn't show page feed results - facebook

Using a system user access token I can make an unpublished post to the feed just fine and I can receive a page access token for that page. However, when I attempt to read the feed using the page access token (from a system user) I receive an empty data result, that is I don't see any posts at all or even my newly created unpublished post.
Per the Graph API 2.1 documentation for read page feeds I should be able to use a page access token to retrieve all posts on the page.
Here are my steps:
GET request to /v2.1/me/accounts using system user access token, result includes access token
POST request with page accesss token to /{page-id}/feed with fields published "false" & message "test", result is post ID (I can verify this post using object id on the graph api)
GET request with page access token to /{page-id}/feed and result is {"data":[]}
If I GET request to /{page-id}/feed with my user access token I'm shown all published posts fine.
What's wrong with my steps or assumptions?

Related

Facebook app token and user token shows different feeds for the same page

I am parsing posts from specified Facebook Page using both app level and user tokens.
And for some reason output is different. User level token gives me 3 posts :
post 1
post 2
post 3
But application token shows only post 3.
Why application token can't get all post from page ?
Facebook page ID is "fifa". Tested both graph api and fql in Graph API Explorer.

Getting page access_token for a Facebook page (using Graph API)

I am trying to access a public FB community page and display the images on web page, example-http://www.codeofaninja.com/2011/06/display-facebook-photos-to-your-website.html
My site is being developed in java, so I am looking for a core java solution to do something like this.
My site does not prompt for the user to login via Facebook or authenticate. I am simply trying to display all the images from my own album on my website.
I have created an FB app, and then created a community page on which I have my pictures.
I am struggling to I authenticate from the backend code of my with my app or page. My app has user_photos permission and the App Type (Apps->Your APP->Advanced->App type) is Web.
Here are the things I tried using graph API:
1) Get access token
https://graph.facebook.com/oauth/access_token?client_id=ABC&client_secret=XYZ&grant_type=client_credentials
2) Then use access token to get access to the page and its albums, but the above gives me app access_token. As mentioned on Graph API documentation for Page it requires a page acess_token, but I am not understanding how do I get the page_access_token via an app access_token with a backend application.
After Page access token is retrieved I can use the following call to retrieve all photos.
https://graph.facebook.com/PAGE_ID/photos?access_token=<page_access_token>
You can make the following Graph API call To get the page access tokens for all the Pages a particular user admin.
https://graph.facebook.com/user_id/accounts?access_token=<user_acess_token>
the app access token that you're retrieving from
https://graph.facebook.com/oauth/access_token?client_id=ABC&client_secret=XYZ&grant_type=client_credentials
can be used to access the public data on a page - you don't need a specific 'page' access token.
this page https://developers.facebook.com/tools/explorer/ is handy for testing things out - plug in the app access token and the page url to try it out
but I am not understanding how do I get the page_access_token via an app access_token with a backend application.
Not at all …
To get a page access token, you have to have a user access token with manage_pages permission first.
(If you get a long-lived user access token, and use that to get the page access token, then the latter will not expire by default.)

Facebook Graph Api access Alcohol Related Page

I am looking for a solution to fetch the feeds of an alcohol-related/age-restricted Facebook Brand Page by a website or back-end service to show these infos in that website for any user.
i.e: https://graph.facebook.com/JimBeam
The standard call results with an error or false.
I know the reason is the age-restictrion because of the relation to alcohol.
If I am connected to Facebook and add an access_token (user-token or page-token) to the request, I get everything I need, but it doesn't work if I am not connected.
If I request the page-token with offline_access, it also does not work when I am not connected to Facebook.
I am a bit confused with all this token types, offline_access, permissions and so on.
Is possible to get the fb-graph-feed of an age-restricted page and load that into a website?
To get an age-restricted feed you need to have a user access token that meets the criteria for the page. So if a user is visiting your site, they will need to authenticate your app, and then you can use the resulting access token to pull information to your website from that restricted page.
You should not be using a user's access token to display content to another user who does not meet the restrictions on the Facebook page.
An added problem is that Facebook does not expose a page's restrictions via the API, so you can't tell if a user has permission to see the page until your API request returns no data.

Facebook API - Posting as self on page I admin

I'm trying to support the ability to post to to a Facebook page as both the user and as the page itself.
As the user, I'm calling the following:
POST https://graph.facebook.com/<page_id>/feed
message=test&access_token=<user_access_token>&format=json
As the page, I'm invoking the same call, except the access_token is the token returned for that page by me/accounts.
In both cases, the post is made by the page.
Is there a way using the API to post as my user to a page I administer?
See 'Actor name will always match the access token' on the Facebook Roadmap - this is a migration to resolve the inconsistency you're encountering here.
Using the User access token of a Page admin can still cause the post to be made as the page depending on what that user has selected in the page management settings on facebook.com - there's an option to 'Always post as even when logged in as '
Enabling that migration causes the post to always be from the owner of the access token (i.e page access token posts as the page, user access token posts as the user)

How to post status updates to Facebook fan page via API?

I have spent the last few days going through Facebook docs and dozens of blogs/websites and I still cant figure out how to post a status update (to a fan page that I manage) via the Facebook API (programatically)?
This is normally a couple lines of code (with every other API in the world). I am just dumbfounded at the complexity and obscurity with Facebook.
Any pointers?
I don't want to build a UI or deal with sessions or use their "SDK", etc etc...I just want to do a RESTful HTTP POST/s (via PHP CURL).
Thanks in advance.
(BTW, I created an app (so I have an AppID and an AppSecret))
First step (which you have done) is to get the user access token with the publish_stream, manage_pages permissions. Call this USER_ACCESS_TOKEN.
Step 2, get the page access token and use that to publish to the page wall. Getting page access_token:
Call to URL /me/accounts with the USER_ACCESS_TOKEN
The result should include your fanpage and corresponding page token. Get that token, call this PAGE_ACCESS_TOKEN
Then to post to the page wall, call /PAGE_ID/feed with your parameters and use the
PAGE_ACCESS_TOKEN
For more details, see https://developers.facebook.com/docs/reference/api/page/ (look for Page Access Tokens and feed sections)