Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all friends' feed from Facebook Graph API

I use php sdk on my facebook app and ask for required extended permission. I can get all statuses update from user who use my application from api call

$statuses = $facebook->api('/me/statuses?limit=0');

But when I use the same method with this user's friend.

$friendStatuses = $facebook->api('/'.$user_id.'/statuses?limit=0');

I got a blank array. I tried to not use "?limit=0" but the result is still the same.

I also tried to use

$friendFeed = $facebook->api('/'.$user_id.'/feed?limit=0');

and got some feed from that user but not all. Even if I change "?limit=0" to "limit=1000" but the feed that I got is around 500 items but that user have more feed than that for sure.

My work is aim on collect user and friends' statuses and clustering them.

like image 315
naokikun Avatar asked Jan 11 '11 16:01

naokikun


People also ask

How do I get data from Facebook Graph API?

Open the Graph Explorer in a new browser window. This allows you to execute the examples as you read this tutorial. The explorer loads with a default query with the GET method, the lastest version of the Graph API, the /me node and the id and name fields in the Query String Field, and your Facebook App.

How do I get Facebook Page Insights on graph API?

Getting Page InsightsIn the Graph API Explorer, click the "Get Access Token" button to obtain the read_insights and manage_pages permissions (listed under "Extended Permissions"). Click "Submit" to retrieve the list of Pages that you admin now that you have a valid access token.

Is Facebook Graph API deprecated?

Applies to all versions. Facebook Analytics will no longer be available after June 30, 2021. Additionally, we are deprecating the App Dashboard Plugin for Marketing API. For more information visit the Business Help Center.

How do I get Facebook posts on API?

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.


1 Answers

The proper way to get a user's friend's feed is the last example you used:

$friendFeed = $facebook->api("/{$user_id}/feed?limit=0");

If you are getting some of the feed items, but not all of the ones you are expecting, it is possible you do not have the right permissions. The read_stream permission to see non-public posts, so, try double checking that you have the read_stream permission. You can check by running the FQL query:

SELECT read_stream FROM permissions WHERE uid = me()

I'm not 100% sure how you would do that with the SDK you are using, but it would probably be:

$readStream = $facebook->api("/method/fql.query?query=SELECT+read_stream+FROM+permissions+WHERE+uid+=+me()");

Good luck!


You can read more about running FQL queries here.
You can read more about the permissions table here.
You can read more about the graph api's User object here.

like image 140
michaelday Avatar answered Sep 18 '22 22:09

michaelday