facebook php - 如何获取专辑封面照片

发布于 2025-01-03 20:53:04 字数 244 浏览 2 评论 0原文

我需要使用 PHP SDK (Facebook) 获取专辑封面照片。 我尝试使用:

https://graph.facebook.com/[ALBUM_ID]/picture?type=album,但我得到默认图像...例如...获取用户 https://graph 的个人资料图片。 facebook.com/[USER_ID]/picture?type=square

有人可以告诉我获取相册封面照片的正确方法吗?

谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

素罗衫 2025-01-10 20:53:04

您可以只使用 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 //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);
    }

您可以在此处找到对所有 FQL 表的引用: http://developers.facebook.com/docs/reference/fql/

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/

最佳男配角 2025-01-10 20:53:04

封面图像的 URL 是 https://graph.facebook.com/[album_id]?fields=picture

其他人解释的 FQL 方法是一种方法。我会这样做:

$albumCover = $facebook->api("/[album_id]?fields=picture", "get");
echo "<img src='".$albumCover['picture']."' />";

The URL for the cover image is https://graph.facebook.com/[album_id]?fields=picture

The FQL method as someone else explained is one way. I'd do it this way:

$albumCover = $facebook->api("/[album_id]?fields=picture", "get");
echo "<img src='".$albumCover['picture']."' />";
新人笑 2025-01-10 20:53:04

专辑的封面照片是专辑第一张上传的图片。如果相册中没有任何图像,封面图像将是一个问号。

The album's cover photo is the album's first uploaded image. If you haven't got any image in the album, the cover image will be a question mark.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文