Facebook php - 如何获得专辑封面照片 [英] facebook php - how to get album cover photo

查看:109
本文介绍了Facebook php - 如何获得专辑封面照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用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表的引用: http://developers.facebook.com/docs/reference/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 - 如何获得专辑封面照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆