问题描述
我需要使用PHP SDK(Facebook)获得专辑封面照片。
我尝试:
https://graph.facebook.com/ [ALBUM_ID] / picture?type = album,但我得到一个默认图像。 ..例如...获取用户的个人资料图片https://graph.facebook.com/ [USER_ID] /图片?type = square
有人可以告诉我正确的方式来收集相册的封面照片。
谢谢。
你可以使用FQL,这是我首选的方法,提供了很大的灵活性。此代码示例应该是您需要的:
$ album_id ='6464156415616';
try {
$ fql ='SELECT pid,src_small FROM photo WHERE pid in(SELECT cover_pid FROM album WHERE aid ='。$ album_id。'AND owner = me())';
$ param = array(
'method'=>'fql.query',
'query'=> $ fql,
'callback'=>''
//,'return_ssl_resources'=> 1 //如果您希望源代码来自https
),请设置此选项;
$ fqlResult = $ facebook-> api($ param);
$ fqlResult ['type'] = $ uploadVal ['type'];
//获取值
$ src_small = $ fqlResult ['src_small'];
} catch(异常$ o){
print_r($ o);
}
您可以在这里找到对所有FQL表的引用:
I need to get the album cover photo with the PHP SDK (Facebook).I try with:
https://graph.facebook.com/[ALBUM_ID]/picture?type=album, but I get a default image... for example... to get profile pic of user https://graph.facebook.com/[USER_ID]/picture?type=square
Somebody can tell me the correct way to get cover photo for albums please.
thanks.
You could just use FQL, it is my preferred method and offers a lot of flexibility. This code sample should be what you need:
$album_id = '6464156415616';
try{
$fql = 'SELECT pid, src_small FROM photo WHERE pid in (SELECT cover_pid FROM album WHERE aid='.$album_id.' AND owner=me())';
$param = array(
'method' => 'fql.query',
'query' => $fql,
'callback' => ''
//,'return_ssl_resources'=>1 //set this option if you want the source to come from https
);
$fqlResult = $facebook->api($param);
$fqlResult['type'] = $uploadVal['type'];
//fetch values
$src_small = $fqlResult['src_small'];
} catch(Exception $o){
print_r($o);
}
You can find a reference to all of the FQL tables here: http://developers.facebook.com/docs/reference/fql/
这篇关于Facebook php - 如何获得专辑封面照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!