get application user's info - Facebook-GRAPH A

2019-09-20 06:22发布

问题:

i need to dump some info of the application user's i am using this code !

$fbme     =   $facebook->api('/me');
$str = $fbme['name'].' '.$fbme['sex'].' '.$fbme['hometown_location'].' '.$fbme['profile_url'].'\r\n';
$fp = fopen("data.txt", "w");
fwrite($fp, $str);
fclose($fp);

but this only shows the name, nothing else ! why ?

回答1:

You're making up property names. It's not sex, it's gender. And so on. Read: http://developers.facebook.com/docs/reference/api/user/



回答2:

    $friends = $facebook->api('me/friends');

    //print_r($friends['data']);
    print_r("Number of friends: ". count($friends['data']));

    foreach ($friends['data'] as $key=>$friendList) {
        echo "<br/>".$key." ".$friendList['name']."<img src='https://graph.facebook.com/".$friendList['id']."/picture' width='50' height='50' title='".$friendList['name']."' />";     
    }