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

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

问题描述

好的,首先让我告诉您,获取用户的相册并循环输出以按我想要的尺寸显示所有照片没有问题.

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.

在这个来自 Facebook 的示例代码中,您将看到在检索相册时,数组中的每张照片都会返回此示例数组中的不同大小.我可以从这里保存缩略图 url,但我不想存储它,只需在需要时检索.

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.

谢谢.

推荐答案

Facebook 为图片字段提供了type 选项,例如,您可以指定如下内容:

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 />

其中类型参数可以是 squaresmallnormallarge 之一,用于个人资料图片或缩略图普通相册用于相册图片.

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

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

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

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

Added different options for album pictures

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

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