Displaying images from Facebook photo albums on a portfolio site using the graph api

前端 未结 2 1064
粉色の甜心
粉色の甜心 2021-02-06 19:27

A client of mine would like to be able to update her site\'s image galleries by adding images to albums on her facebook account. Is this possible using JSON? would the albums sh

2条回答
  •  悲哀的现实
    2021-02-06 19:59

    This is definitely possible by using the graph api:

    Get the ID of all of her albums - select the one you want:

    https://graph.facebook.com/me/albums/

    Access the album:

    https://graph.facebook.com/ALBUM_ID/photos

    You need the user_photos permission and the album needs to be public.

    This returns you a list of all the photos in the following JSON form:

    {
              "id": "104988432890979",
                     "from": {
                        "name": "Patrick Snape",
                        "id": "100001394674670"
                     },
                     "picture": "http://photos-f.ak.fbcdn.net/hphotos-ak-snc4/hs272.snc4/39934_104988432890979_100001394674670_46790_6171664_s.jpg",
                     "source": "http://sphotos.ak.fbcdn.net/hphotos-ak-snc4/hs272.snc4/39934_104988432890979_100001394674670_46790_6171664_n.jpg",
                     "height": 540,
                     "width": 720,
                     "link": "http://www.facebook.com/photo.php?pid=46790&id=100001394674670",
                     "icon": "http://static.ak.fbcdn.net/rsrc.php/z2E5Y/hash/8as8iqdm.gif",
                     "created_time": "2010-08-11T10:32:45+0000",
                     "updated_time": "2010-08-11T10:32:47+0000"
                  }
    }
    

    You can then use the source of the photo to get the full sized image

提交回复
热议问题