I recently created an app in Facebook. By default the API version used was v2.0. Thus for every new user it generated a 'App-scoped User ID'. I am retrieving the ids of users through the graph api search feature.
Now I want to use the /{user-id}/feed to fetch feed of a specific user.
Is there a way I can access a specific user's feed using an access token generated for my Facebook account through a Facebook app?
Page and User is different thing. For page, you can access PAGE_ID/feed easily with App Access Token if this post is not restriced (age, gender...etc).If the post is restricted, then you must use User access token to access this posts.
For user is different story, Facebook is very strict on user feed. So you must use User access token to get User_ID/feed.
I suggest you to do like that way:
- If the user is your app user authorized with read_stream permission, then you access the USER_ID/feed. It's because USER_ID/feed endpoint only available if user give permission read_stream to your app. App Access Token is not allow.
- If the user is not your app user with read_stream, then you access the USER_ID/links instead. It's because no read_stream permission require to access this endpoint. App Access Token is not allow.
- If this is a page, then you access the PAGE_ID/feed(better) or PAGE_ID/links. App Access Token is allow except restricted posts. So it's better to use User Access Token.
As document stated:
Any valid access token is required to view public links.
This statement is wrong and misleading because App Access Token may able to read PAGE_ID/links(non-restricted post) but it can't read the USER_ID/links endpoint.
Theres's some other variant endpoints, e.g. USER_ID/statuses, in which:
App access token not allow.
If the user A did not give permission user_status to app X, then (App X)User A Access Token access user_A_ID/statuses will only return status type posts post via app X.
If the user A did give permission user_status to app X, then (App X)User A Access Token access user_A_ID/statuses will return all status type posts without app restriction.
If the user A did not give permission user_status to app X, then (App X)User B Access Token access user_A_ID/statuses will not return any data.
If the user A did give permission user_status to app X, then (App X)User B Access Token access user_A_ID/statuses will return all status type posts without app restriction which was public.
Update:
Facebook API changed again and now USER_ID/links only accessible for the same app user id.
I doubt that this is possible with Graph API v2.0 Have a look at https://developers.facebook.com/docs/graph-api/reference/v2.0/user/feed/#readperms
Quote:
- Any valid access token is required to view public links.
- A user access token with read_stream permission is required.
- Only posts whose authors have also granted read_stream permission to the app will be shown.