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
Sure you can retrieve photos from users that have added you application and agreed to share such information. First you retrieve the albums using the photos_getAlbums API call, then you can loop over album ids and call photos_get to retrieve photos for the albums.
/**
* get_albums()
*
* @param long $uid
* @return array
*/
function get_albums($uid=null)
{
if (empty($uid))
$uid = $_REQUEST['fb_sig_user'];
try
{
return $facebook->api_client->photos_getAlbums($uid,null);
}
catch (FacebookRestClientException $ex)
{
return array();
}
}
/**
* get_photos()
*
* @param bool $bool_pids
* @param mixed $aids (array of album ids or null)
* @return array
*/
function get_photos($bool_pids=true, $aids=null, $pids=null)
{
try
{
$p = $facebook->api_client->photos_get(null, $aids, $pids);
}
catch (FacebookRestClientException $ex)
{
}
if ($bool_pids)
{
$pids = array();
if (!empty($p))
foreach($p as $p0)
$pids[] = $p0['pid'];
return $pids;
}
else
return $p;
}