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

前端 未结 2 840
我在风中等你
我在风中等你 2021-02-06 19:29

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:51

    https://graph.facebook.com/USER_ID/albums/ would get you 25 most recent albums and you must set the 'limit=0' in the url like

    https://graph.facebook.com/USER_ID/albums/?limit=0 this would get u all the albums... and also make sure your album 'Wall Photos' is set to public otherwise you'll require 'user_photos' permission.

    then you need to get the album id of the album with title 'Wall Photos' and you can retrieve the photos using that album id

    $wall_album_id='';
    $url = "http://graph.facebook.com/me/albums?fields=id,name&limit=0";
    $obj = json_decode(file_get_contents($url));
    foreach($obj->data as $item) {
        if ($item->name == 'Wall Photos'){
                $wall_album_id=$item->id;
                break;
        }
    }
    

    you can then use the album '$wall_album_id' to get the wall photos...

提交回复
热议问题