How to Recover Facebook Friends List

Asked

Viewed 2,967 times

5

People I need to return to facebook friends list using facebook API 4 for PHP. I can log in, get the account information but the list only comes the following result for me:

Array
(
[data] => Array
    (
    )

[summary] => stdClass Object
    (
        [total_count] => 124
    )

)

I’m using the following command:

$friends = (new FacebookRequest($session, 'GET', '/me/friends'))
->execute()
->getGraphObject()
->asArray();
echo '<pre>' . print_r( $friends, 1 ) . '</pre>';

And I have the following permissions:

$permissions = array(
'email',
'public_profile',
'user_friends'
 );
 echo '<a href="' . $helper->getLoginUrl($permissions) . '">Login</a>';

How should I return friends?

  • 1

    Has your APP ever been through the Facebook Review? Yes, according to documentation, when you request more than one of these permissions (public_profile, email, user_friends), the APP needs to be reviewed by Facebook.

1 answer

1


First go to your settings and see if Taggable-Friends is enabled for you (https://www.webniraj.com/wp-content/uploads/2014/06/Taggable-Friends.png).

This will retrieve the Taggable-Friends list:

<?php

// requer Facebook PHP SDK 4.0.x ou +

// 

// pegar taggable friends
$taggable = (new FacebookRequest( $session, 'GET', '/me/taggable_friends' ))->execute()->getGraphObject()->asArray();

// output response
echo '<pre>' . print_r( $taggable, 1 ) . '</pre>';

// output total friends
echo count( $taggable['data'] );

Source: https://www.webniraj.com/2014/06/12/facebook-api-getting-friends-using-graph-api-2-0-and-php-sdk-4-0-x/

  • That’s right. I did it like this and it worked. Thanks

  • In need you can ask!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.