Thursday, February 10, 2011

Import Photo From Facebook

I was trying to import the photo of the login use of the facebook.I'm putting the step follow those steps and get all the picture of the user.

Step of the import image of the user.

1. Make the Application in facebook (get the api key and secret key)
2. then you need to write following code on the page and upload that page any server.
3. you can click the login page and put the login credential (login name password) after that you can see the all photo of the login user..

code is below there :

require 'facebook.php';
// Create our Application instance.
$facebook = new Facebook(array(
'appId' => 'API key here ',
'secret' => 'Secret Key here',
'cookie' => true,
));

$session = $facebook->getSession();
$me = null;

if ($session) {
try {
$uid = $facebook->getUser();
$me = $facebook->api('/me');
$token = $session['access_token'];
} catch (FacebookApiException $e) {
error_log($e);
}
}


if ($me) {
$logoutUrl = $facebook->getLogoutUrl();

} else {
$loginUrl = $facebook->getLoginUrl(array('req_perms' => 'email,user_birthday,status_update,publish_stream,user_photos,user_videos'));

}
?>



$fql_query = array(
'method' => 'fql.query',
'query' => 'SELECT src FROM photo WHERE aid IN ( SELECT aid FROM album WHERE owner='.$uid.' ) ORDER BY created DESC LIMIT 1,42');

$photo = $facebook->api($fql_query);

/*for($i=0; $i{
//echo ''.$me['name'].'';
} */
echo '';
}
else
{
?>
onlogin="Log.info('onlogin callback')">
Login



//echo '';
}
?>