Facebook Graph API - How do you retrieve the different size photos from an album?

后端 未结 3 1336
孤城傲影
孤城傲影 2020-12-13 06:55

Ok, first off let me tell you I have no problems getting a user\'s photo album(s) and looping through the output to display all of the photos in the size I want.

Ho

相关标签:
3条回答
  • 2020-12-13 07:22

    here src_big and src are different size image url source

        function get_photos_by_album_id($album_id){
    
     if($album_id)
         $fql            =   'SELECT pid,src_big,owner,link,position,created,caption,src      FROM photo WHERE aid="'.$album_id.'" ORDER BY created DESC LIMIT 0,6';
    
                $param  =   array(
                'method'    => 'fql.query',
                'query'     => $fql,
                'callback'  => ''
            );
            $fqlResult   =   $this->facebook->api($param);
        return $fqlResult;
    
     }
    
    0 讨论(0)
  • 2020-12-13 07:32

    Thought I'd share a little trick in getting larger image sizes from the Graph API. Facebook as a little convention with image URLs that's not very obvious. For instance, take the following URL:

    https://fbcdn-photos-g-a.akamaihd.net/hphotos-ak-prn2/t1/1185356_10201176263222205_1153673992_s.jpg

    Notice the _s.jpg at the end? That determines the size of the image. You can change this to _o.jpg to get the "original" full size version. In other words, update the image URL to:

    https://fbcdn-photos-g-a.akamaihd.net/hphotos-ak-prn2/t1/1185356_10201176263222205_1153673992_o.jpg

    Every Facebook image has an _o.jpg version. Worst case, you get something the same size as the thumbnail. If that's the case, you're no better off than you were before.

    0 讨论(0)
  • 2020-12-13 07:39

    Facebook provides a type option for the picture field, for example, you can specify something like:

    <img src="https://graph.facebook.com/xxx/picture?access_token=yyy&type=normal />
    

    where the type parameter can be one of square, small, normal, or large for profile pictures or thumbnail, normal, album for album pictures.

    Source: http://developers.facebook.com/docs/reference/api/user/ (under Connections section)

    Edit: Added different options for album pictures

    0 讨论(0)
提交回复
热议问题