I\'m using the most recent version of the Facebook SDK (which lets to connect to something called the \'graph API\' though I\'m not sure). I\'ve adapted Facebook\'s example
I think this is what you want:
$friends = $facebook->api('/me/friends');
in the recent version of facebook sdk , facebook has disabled the feature that let you access some one friends list due to security reasons ... check the documentation to learn more ...
Using CodeIgniter OAuth2/0.4.0 sparks,
in Auth.php file,
$user = $provider->get_user_info($token);
$friends = $provider->get_friends_list($token);
print_r($friends);
and in Facebook.php file under Provider, add the following function,
public function get_friends_list(OAuth2_Token_Access $token)
{
$url = 'https://graph.facebook.com/me/friends?'.http_build_query(array(
'access_token' => $token->access_token,
));
$friends = json_decode(file_get_contents($url),TRUE);
return $friends;
}
prints the facebenter code hereook friends.
header('Content-type: text/html; charset=utf-8');
input in your page.
Use FQL instead, its a like SQL but for Facebook's data tables and easily covers data query you'de like to make. You won't have to use all of those /xx/xxx/xx calls, just know the tables and columns you are intereseted in.
$myQuery = "SELECT uid2 FROM friend WHERE uid1=me()";
$facebook->api( "/fql?q=" . urlencode($myQuery) )
Great interactive examples at http://developers.facebook.com/docs/reference/fql/
This is live version of PHP Code to get your friends from Facebook
<?php
$user = $facebook->getUser();
if ($user) {
$user_profile = $facebook->api('/me');
$friends = $facebook->api('/me/friends');
echo '<ul>';
foreach ($friends["data"] as $value) {
echo '<li>';
echo '<div class="pic">';
echo '<img src="https://graph.facebook.com/' . $value["id"] . '/picture"/>';
echo '</div>';
echo '<div class="picName">'.$value["name"].'</div>';
echo '</li>';
}
echo '</ul>';
}
?>