How to access all your friends from the Facebook Graph API

I am using php sdk in my facebook application and request the required extended resolution. I can get all status updates from a user who uses my application from api call

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

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

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

I got an empty array. I tried not to use "? Limit = 0", but the result is still the same.

I also tried using

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

and received some feed from this user, but not all. Even if I changed "? Limit = 0" to "limit = 1000", but I have about 500 elements, but this user has more feed than that for sure.

My work is aimed at collecting the statuses of users and friends and their clustering.

+8
php facebook facebook-graph-api
source share
2 answers

The correct way to get the feed for the user is the last example you used:

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

If you get some feed items, but not all that you expect, you may not have rights. Read_stream permission to view non-public messages, so try double checking that you have read_stream permission. You can verify by running the FQL query:

 SELECT read_stream FROM permissions WHERE uid = me() 

I am not 100% sure how you will do this with the SDK you are using, but this will probably be:

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

Good luck


You can learn more about FQL query execution here .
Learn more about the permissions table here . You can learn more about the custom object api graphics here .

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

use it, count your friends faster

0
source share

Source: https://habr.com/ru/post/650935/


All Articles