How to retrieve Facebook friends list

5

Personal I need to return the facebook friends list using the facebook 4 for PHP API. I can login, get the account info but the list only comes the following result for me:

Array
(
[data] => Array
    (
    )

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

)

I am 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 do I return friends?

    
asked by anonymous 15.01.2015 / 13:47

1 answer

1

First go to your settings and see if Taggable-Friends is enabled for you ( link ).

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: link

    
15.01.2015 / 19:22