Sometimes, it’s great to see a Facebook user registering on your site, but what if we can show them list of friends in your site, it will be amazing.
This is a one page PHP script, that uses facebook PHP sdk to list facebook friends. Friends will be listed pagewise, and how many friends to show per page can also be set. Just change variables on top of script with your own and enjoy.
[cc lang=”php”]
$appid,
‘secret’ => $appsecret,
));
$fbuser = $facebook->getUser();
if ($fbuser) {
try {
$access_token = $facebook->getAccessToken();
$me = $facebook->api(‘/me’);
} catch (FacebookApiException $e) {
die($e->getMessage());
}
}
// Show login form if fresh login requires
if (!$fbuser){
$loginUrl = $facebook->getLoginUrl(array(‘redirect_uri’=>$scriptPath));
die(‘Login‘);
}
$offsetValue=”;
$previousurl=”;
$nexturl=”;
if(isset($_GET[“offset”]) && is_numeric($_GET[“offset”]))
{
$offsetValue=’&offset=’.$_GET[“offset”];
}
$friends = $facebook->api(‘/me/friends?limit=’.$friendsPerPage.$offsetValue);
if(isset($friends[“paging”][“next”]))
{
$nexturlOffset = returnFbOffset($friends[“paging”][“next”]);
$nexturl = ‘Next »‘;
}
if(isset($friends[“paging”][“previous”]))
{
$previousurlOffset = returnFbOffset($friends[“paging”][“previous”]);
$previousurl = ‘« Previous‘;
}
?>
Friend List
‘.$previousurl.’ | ‘.$nexturl.’
In cake php where i have to put this code with usermanagemnet plugins
from this site i got refrence from ur site.
I want show freinds list in my page.
codezones.info/social-login-and-simple-acl-plugin-in-cakephp/
plugings contain name,profile name ,image etc but not show freinds list
it just does not :(
$scriptPath = 'http://path-to-this/script/'; //path to script
what script to you mean???
can you pls give me a demo, i am new with sdks and apis and i need this so fast :(
lg bjoern
$scriptPath is the absolute link to the file on which you are using this code. Its basically acting as the call back URL.
Sebastian
hello, I was wondering if you could build upon this or if would would be interested in working on a project that has this functionality plus a little more stuff added to it...I will even pay you , or if you want to do a tutoria. This demo was AWSOME!