How to get user posts using Graph API?

I want to fetch all the public posts from a user's wall with my user access token. I know that read_stream permission is required for this. However this permission has been deprecated now.

https://developers.facebook.com/docs/facebook-login/permissions#reference-read_stream

read_stream

This permission is only available for apps using Graph API version v2.3 or older.

I want to use version v2.5, so how can I do this now?


/me/feed gives you posts published by this person.

Filtered versions are:

/me/posts shows only the posts published by this person.

/me/tagged shows only posts that this person is tagged in.

Your app needs user_posts permission from the person who created the post or the person tagged in the post.

Then your app can read:

Timeline posts from the person who gave you the permission. The posts that other people made on that person Timeline. The posts that other people have tagged that person in.

If you attempt to read data from a feed that your app has not been authorized to access, the call will return an empty array.

For more details: https://developers.facebook.com/docs/graph-api/reference/v2.5/user/feed

Edit : From a user access token, you can only get feed of that user and his facebook friends who are users of this app. Also all those users must grant user_posts permission to your app otherwise it will return only empty data set like in your case

For other users ( who have granted user_posts permission and friend of current access token user ) feed use: /{user_id}/feed

{user_id} of friends ( who are also user of your app ) available in /me/friends


Use the /me/posts endpoint with the user_posts permission:

We have a new permission user_posts that allows an app to access the posts on a person's Timeline. This includes the someone's own posts, posts they are tagged in and posts other people make on their Timeline. Previously, this content was accessible with the read_stream permission. The user_posts permission is automatically granted to anyone who previously had read_stream permission.

Source: https://developers.facebook.com/docs/apps/changelog#v2_3

That´s all you can get, there is no way to get the whole feed anymore. It does not matter if the posts are public or not btw.

You need to use a User Token with the user_posts permission, debug your Token and make sure it includes that permission: https://developers.facebook.com/tools/debug/

More information about Tokens:

  • https://developers.facebook.com/docs/facebook-login/access-tokens
  • http://www.devils-heaven.com/facebook-access-tokens/
  • 链接地址: http://www.djcxy.com/p/32628.html

    上一篇: 如何使用访问令牌获取Facebook用户标识

    下一篇: 如何使用Graph API获取用户帖子?