1
I used the following code, to access the albums of a fan page on facebook:
$cUrl = new cUrl;
$fb_page_id = "xxxx";
$json_link = "http://graph.facebook.com/{$fb_page_id}/albums?fields=id,name,description,link,cover_photo,count,created_time";
$json = $cUrl->file_get_contents_curl($json_link);
/*$obj = json_decode($json, true, 512, JSON_BIGINT_AS_STRING);*/
$obj = json_decode(preg_replace('/("\w+"):(\d+)/', '\\1:"\\2"', $json), true);
$album_count = count($obj['data']);
for($x=0; $x<$album_count; $x++):
$id = $obj['data'][$x]['id'];
$name = $obj['data'][$x]['name'];
/*$description = $obj['data'][$x]['description'];*/
$link = $obj['data'][$x]['link'];
$cover_photo = $obj['data'][$x]['cover_photo'];
$count = $obj['data'][$x]['count'];
$data_s-> usarData($obj['data'][$x]['created_time']);
// if you want to exclude an album, just add the name on the if statement
if(
$name!="Profile Pictures" &&
$name!="Untlited Album"
){
$show_pictures_link = "?album_id={$id}&album_name={$name}";
echo $data_s->data();
echo "{$name}";
}
There was some HTML in the code, but that’s beside the point. It worked very well, but now nothing appears. Does anyone know why? or has another method?
There’s a gap between the
?
and the parametershttp://graph.facebook.com/{$fb_page_id}/albums? fields=id,name,description,link,cover_photo,count,created_time
, seems wrong.– Guilherme Nascimento
https://developers.facebook.com/docs/graph-api/reference/v2.4/album
– Jefferson Silva
Hello William, it was a mistake to organize here in the question. But he is caught even.
– Soares