Facebook Graph API - 如何从相册中检索不同大小的照片? [英] Facebook Graph API - How do you retrieve the different size photos from an album?

查看:103
本文介绍了Facebook Graph API - 如何从相册中检索不同大小的照片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,首先让我告诉你,我没有问题获取用户的相册,并循环输出以显示所需的大小的所有照片。



但是,如果我想打电话给照片:

  < img src =https://graph.facebook.com/<?=$this->session->page->photo_id?>/picture?access_token=<?=$this-> ;会话而>成员 - > facebook_access_token>? /> 

我不知道如何告诉我要显示的大小。



在Facebook的这个示例代码中,您将看到,在该示例数组中,每个照片中的每张照片都会返回相应的大小。我可以保存缩略图URL,但是我不想存储它,只需在需要时检索。

  { 
id:10150146071831729,
from:{
name:Facebook,
category:Product / service,
id:20531316728
},
picture:http://photos-g.ak.fbcdn.net/hphotos-ak-ash1/168119_10150146071831729_20531316728_7844072_5116892_s.jpg,
source:http://a7.sphotos.ak.fbcdn.net/hphotos-ak-ash1/168119_10150146071831729_20531316728_7844072_5116892_n.jpg,
height:483,
width: 720,
图像:[
{
height:483,
width:720,
source:http:// a7

{
height:120,
width:180,.sphotos.ak.fbcdn.net / hphotos-ak-ash1 / 168119_10150146071831729_20531316728_7844072_5116892_n.jpg
source:http://photos-g.ak.fbcdn.net/hphotos-ak-ash1/168119_1015014607183172 9_20531316728_7844072_5116892_a.jpg
},
{
height:87,
width:130,
source:http:// photos- g.ak.fbcdn.net/hphotos-ak-ash1/168119_10150146071831729_20531316728_7844072_5116892_s.jpg
},
{
height:50,
width:75,
source:http://photos-g.ak.fbcdn.net/hphotos-ak-ash1/168119_10150146071831729_20531316728_7844072_5116892_t.jpg
}
],
... ....继续...
}

必须有一种方法来检索这些不同的大小。



谢谢。

解决方案

strong> type 选项,例如,您可以指定以下内容:

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

其中type参数可以是 square 之一, / em>



资料来源: http://developers.facebook.com/docs/reference/api/user/ (在连接部分下)



编辑:为相册图片添加了不同的选项


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.

However, if I want to call a photo like:

<img src="https://graph.facebook.com/<?=$this->session->page->photo_id?>/picture?access_token=<?=$this->session->member->facebook_access_token?>" />

I cannot figure out how to tell it the size I want it to show.

In this sample code from Facebook you will see that whey retrieving the album each photo in the array comes back with the different sizes in this sample array. I could just save the thumbnail url from this, but I don't want to store it, just retrieve when needed.

{
   "id": "10150146071831729",
   "from": {
      "name": "Facebook",
      "category": "Product/service",
      "id": "20531316728"
   },
   "picture": "http://photos-g.ak.fbcdn.net/hphotos-ak-ash1/168119_10150146071831729_20531316728_7844072_5116892_s.jpg",
   "source": "http://a7.sphotos.ak.fbcdn.net/hphotos-ak-ash1/168119_10150146071831729_20531316728_7844072_5116892_n.jpg",
   "height": 483,
   "width": 720,
   "images": [
      {
         "height": 483,
         "width": 720,
         "source": "http://a7.sphotos.ak.fbcdn.net/hphotos-ak-ash1/168119_10150146071831729_20531316728_7844072_5116892_n.jpg"
      },
      {
         "height": 120,
         "width": 180,
         "source": "http://photos-g.ak.fbcdn.net/hphotos-ak-ash1/168119_10150146071831729_20531316728_7844072_5116892_a.jpg"
      },
      {
         "height": 87,
         "width": 130,
         "source": "http://photos-g.ak.fbcdn.net/hphotos-ak-ash1/168119_10150146071831729_20531316728_7844072_5116892_s.jpg"
      },
      {
         "height": 50,
         "width": 75,
         "source": "http://photos-g.ak.fbcdn.net/hphotos-ak-ash1/168119_10150146071831729_20531316728_7844072_5116892_t.jpg"
      }
   ],
   ....... continued...
}

There has to be a way to retrieve these different sizes.

Thanks.

解决方案

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

这篇关于Facebook Graph API - 如何从相册中检索不同大小的照片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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