1. Download the facebook sdk zip file from this link and extract it;

2. create a new folder “fb”.

3. Copy the file from the downloaded sdk src folder and paste it in the fb folder.

4. now add the following code to display the images of your facebook friends with pagination..

5. Just copy and paste the below code which check the facebook authentication and show the images

<?php
$appid          = "xxxx"; //facebook app id
$appsecret      = "xxxxx"; //facebook app secret
$scriptPath         = "http://example.com"; //path where script are..
$friendsPerPage     = 12; //number of friends per page

if (!class_exists("FacebookApiException")) {
    require_once("facebook.php" ); //include facebook api
}
        $facebook = new Facebook(array(
          "appId" => $appid,
          "secret" => $appsecret,
        ));

        $fbuser = $facebook->getUser(); // get the user session
        if ($fbuser) // check user exists or not

 {
          try {
            $access_token = $facebook->getAccessToken();
            $me = $facebook->api("/me");
            } catch (FacebookApiException $e) {
            die($e->getMessage());

          }
        }

        // Show login form if fresh login requires
        if (!$fbuser) //if user not exist then send to the  login page

{
         $loginUrl = $facebook->getLoginUrl(array("redirect_uri"=>$scriptPath));
         die("Login");
        }

        $offsetValue="";
        $previousurl="";
        $nexturl="";

// offset is used as a token which used to limit the no. of friends
        if(isset($_GET["offset"]) && is_numeric($_GET["offset"]))
        {
            $offsetValue="&offset=".$_GET["offset"];
        }
// limit the friends according to  the 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";
        }
?>





<?php
    echo "
“.$previousurl.” | “.$nexturl.”

“;
echo ”

      • “;
      • foreach ($friends[“data”] as $friend) {
      echo ”

    • “;
      echo “”;
      echo ”

      “.$friend[“name”].”

      “;
      echo “

“;
}
echo ”

“;
echo ”

“;

function returnFbOffset($url)
{
$str = parse_url($url); //exploded the url into array
parse_str($str[“query”], $strarray);

/*
parse_str(str,arr);

parse_str: Parses the string into variables
str : input string
arr: variables are stored in this array
*/
return $strarray[“offset”]; // retuning offset value by reading the url
}

?>


7. You can view the