I noticed when I visit photo printing websites, they ask you if you would like to import your photos from Facebook. How do they do it? Does Facebook provide API to import us
get_albums returns an array of albums, do a var_dump to see what it returns.
$albums = get_albums($facebook);
foreach($albums as $album)
{
if($album["count"] > 0)
{
//if the album has pictures, then do something with the album
}
}
function get_albums($facebook)
{
$fb_user = getFbUser($facebook);
$myalbums = $facebook->api('/me/albums');
return $myalbums["data"];
}
function getFbUser($facebook)
{
$fb_user = $facebook->getUser(); //gets user id
if(is_null($fb_user))
{
header("Location:{$facebook->getLoginUrl(array('req_perms' => 'user_status,publish_stream,user_photos'))}");
exit;
}
return $fb_user;
}
function getFb()
{
$facebook = new Facebook(array(
'appId' => 'your_appid',
'secret' => 'your_secret',
'cookie' => true,
));
return $facebook;
}
See: http://www.joeyrivera.com/2010/facebook-graph-api-app-easy-w-php-sdk/