facebook Graph api fetch list of all friends

203 views Asked by At

I am working in a project where i have to integrate face-book graph-api. Everything is going well but i stuck in a problem to fetch my face book friend list using /me/friends/. It return me only those friends which has log in with my app, but i want my all friend list

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

It return [data] => Array ( [0] => stdClass Object ( [name] => Nitin Chamola [id] => 792718557454395 )

        [1] => stdClass Object
            (
                [name] => Ajay Aggarwal
                [id] => 765446336856080
            )

        [2] => stdClass Object
            (
                [name] => Manjit Singh Jassal
                [id] => 1538019986415496
            )

        [3] => stdClass Object
            (
                [name] => Sapna Thakur
                [id] => 1518184435101741
            )

    )

[paging] => stdClass Object
    (
        [next] => https://graph.facebook.com/v2.2/1587893521432407/friends?access_token=CAAGPXznoOFkBAOCKznoJ4AwZBi9DhlNQYuvgn1qT1Qz3x0JE5mUT5JXOnEnhPtpcriJjoRB5K2yNW3B2L0PtJEcgy8MK3NbZB2oHeBPEeayudFSSxDDOTYUc4J3Q9zDkBqsIGcDcHyzECBtHqOM2HKRUwdOmsSRAJQ41lVWj0T1O2bH1P4ZC2Or2Gv0FuVTL7Wp2xudgGsDHyjwLvGT&limit=25&offset=25&__after_id=enc_AexVs_nuUmTOuF4B5iplPfzsuPs6vtQGx7TV_pH-cINIX2nUIvn3vdmWzNINrKx-vqDnpavxrIA_kr3aqSr6lw4k
    )

[summary] => stdClass Object
    (
        [total_count] => 242
    )
1

There are 1 answers

0
Kaveesh Kanwal On BEST ANSWER

After Graph API 2 and above you can no longer do this. You can only fetch the list of those friends who use your app i,e who have given permission to your app. This has been done by fb for security reasons.