Assuming you have instantiated the facebook class (here, "$Fb"),
and given your id and secret...
"$user" is facebook "user_id" (ie 12345678...) of the user of which we want the list of friends
$access_token = $Fb->getAccessToken();
$user_profile = $Fb->api( /me );
// show user image
$txt .= "<p align="center">
<img src="https://graph.facebook.com/".$user."/picture"></p>";
$FBid = $user_profile[ id ];
$FBnick = $user_profile[ username ];
$txt .= fb_friends_list($user_profile,$access_token);
echo ($txt);
上文提到以下职能:获得朋友名单:
function fb_friends_list($fbup,$access_token)
{
// display the friends list on 3 columns, with their avatar.
global $Sess,$Fb;
$friends = $Fb->api( /me/friends ); // return an array [data][0 to n][name]/[id]
$siz = sizeof($friends[ data ]);
$txt = "<h3 align="center">Your FRIENDS on FACEBOOK</h3>";
$txt .= "<table align="center">
<tr>
<td class="blu s12 bld">Friend s<br />Avatar</td>
<td class="blu s12 bld">Friend s Name</td>
<td width="30px"> </td>
<td class="blu s12 bld">Friend s<br />Avatar</td>
<td class="blu s12 bld">Friend s Name</td>
<td width="30px"> </td>
<td class="blu s12 bld">Friend s<br />Avatar</td>
<td class="blu s12 bld">Friend s Name</td>
</tr>";
$col = 0;
for ($i=0; $i<$siz; $i++)
{
$fid = $friends[ data ][$i][ id ];
$src = "http://graph.facebook.com/".$fid."/picture";
if ($col == 0)
$txt .= "<tr>";
$txt .= "<td><img src="".$src."" /></td>";
$txt .= "<td>".$friends[ data ][$i][ name ] . "</td>";
$txt .= "<input type="hidden" name="".$fid."" />";
$col++;
if ($col < 3)
$txt .= "<td width="30px"> </td>";
if ($col == 3)
{
$col = 0;
$txt .= "</tr>";
}
}
if ($col != 0)
$txt .= "</tr>";
$txt .= "</table>";
return($txt);
}
希望能为你们工作!