facebookのphotos & albums API fanページ限定

facebookのjsonの取得に関して少し調べたのでメモ。

情報元以下のページを確認。
https://developers.facebook.com/docs/reference/api/

アルバムのid取得

1)自分のIDでグラフAPIからアルバムのIDを取得
http://graph.facebook.com/294232363956914/albums

{
   "data": [
      {
         "id": "294232820623535",←アルバムのID
         "from": {
            "name": "Take Album",
            "category": "Community",
            "id": "294232363956914"
         },
         "name": "Profile Pictures",
         "link": "https://www.facebook.com/album.php?fbid=294232820623535&id=294232363956914&aid=68544",
         "cover_photo": "294241463956004",
         "count": 3,
         "type": "profile",
         "created_time": "2012-01-02T15:06:51+0000",
         "updated_time": "2012-01-02T15:16:52+0000",
         "can_upload": false
      }
   ],
   "paging": {
      "previous": "http://graph.facebook.com/294232363956914/albums?limit=25&since=1325516811&__paging_token=294232820623535&__previous=1",
      "next": "http://graph.facebook.com/294232363956914/albums?limit=25&until=1325516811&__paging_token=294232820623535"
   }
}

2)アルバムのIDからすべてのアルバムIDを取得
http://graph.facebook.com/294232820623535/albums
アルバムのIDがjsonで取得できる。とりあえず、必要なjsonの中身。

{
   "data": [
      {
         "id": "アルバム01のID",
         "from": {
            "name": "管理人の名前",
            "category": "fanページのカテゴリ",
            "id": "fanページのID"
         },
         "name": "アルバムの名前",
         "link": "アルバムのURL",
         "cover_photo": "28***648",
         "count": 登録写真数,
         "type": "normal",
         "created_time": "2011-12-13T01:21:30+0000",
         "updated_time": "2011-12-13T01:21:50+0000",
         "can_upload": false,
         "likes": {
            "data": [
               {
                  "id": "1***2",
                  "name": "****b50***"
               }
            ],
            "paging": {
               "next": "http://graph.facebook.com/28***99**/likes?limit=25&offset=25&__after_id=10****62****"
            }
         }
      }・・・・・

3)アルバムIDから写真のデータを取得
http://graph.facebook.com/アルバム01のID/photos
{
   "data": [
      {
         "id": "写真のID",
         "from": {
            "name": "管理人の名前",
            "category": "fanページのカテゴリ",
            "id": "fanページのID"
         },
         "name": "写真の名前",
         "picture": "サムネイルのパス",
         "source": "写真のパス",
         "height": 479,
         "width": 720,
         "images": [
            {
               "height": 479,
               "width": 720,
               "source": "写真大のパス"
            },
            {
               "height": 119,
               "width": 180,
               "source": "写真中のパス"
            },
            {
               "height": 86,
               "width": 130,
               "source": "写真小のパス"
            },
            {
               "height": 49,
               "width": 75,
               "source": "写真極小のパス"
            }
         ],
         "link": "写真のページのURL",
         "icon": "http://static.ak.fbcdn.net/rsrc.php/v1/yz/r/StEh3RhPvjk.gif",
         "created_time": "2011-12-13T01:21:35+0000",
         "position": 1,
         "updated_time": "2011-12-13T01:23:06+0000"
      },

 

 

 

関連記事