开发者

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.


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.


$num = 0;
$result = $facebook->api( array('method' => 'fql.query', 'query' => 'SELECT uid2 FROM friend WHERE uid1=me()') );
foreach($result as $photo){
$num++;
}

use this, it is the faster to count your friends

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜