0

Hello
I getting current user friends list by php api of facebook.
can you suggest me what is missing.LINK

<?php
require 'facebook.php';

$facebook = new Facebook(array(
    'appId' => 'removed',
    'secret' => 'removed',
));

if($facebook->getUser() == 0){
    $login = $facebook->getLoginUrl();
    echo "<a href= '$login'>Login with Facebook</a>";
}
else{

        $user_profile = $facebook->api('/me');
        $user_friends = $facebook->api('/me/friends');
        $access_token = $facebook->getAccessToken();


    echo "<pre>";
    print_r($user_profile);
    echo "</pre>";
    echo "<br/>";


    echo "<pre>";
    print_r($user_friends);            //Given NULL Value
    echo "</pre>";
}
?>

Edited by pritaeas: Never post your app id's and secret keys.

3
Contributors
8
Replies
49
Views
2 Years
Discussion Span
Last Post by Itirk
0

print_r($user_friends); given null
i want his friend list data in array

0

'/me' given array of current user data who is login.(eg.firstname,lastname,id etc.)

0

I have also given permission of [permission] => user_friends & [permission] => read_friendlists

2

Given solution : Facebook Faq

Version Information:

In v2.0 of the API, /me/friends returns friends who also have logged into the app.

Apps created on or after April 30th 2014 must use Graph API v2.0; they're not able to call Graph API v1.0.

For apps which existed before April 30th, these apps can call either Graph API v2.0 or Graph API v1.0, but Graph API v1.0 will be deprecated on April 30th 2015.

Note that if a user logs into an app via v2.0, and you call /v1.0/me/friends, this will still only return app-using friends.

If you want to access non-app-using friends in the case where you want to let your users tag people in stories you publish to Facebook, you can use the /me/taggable_friends API.

0

how to set ermission of [permission] => user_friends & [permission] => read_friendlists in cakephp . pls help me urgent

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.