Facebook API: Get all profile pictures

后端 未结 6 1745
野的像风
野的像风 2020-12-23 21:26

What is the best way to get ALL profile pictures from a given user? What permissions do I need?

I know I can access the main profile pic using https://graph.fa

6条回答
  •  忘掉有多难
    2020-12-23 22:20

    To get all profile pictures, firstly you need to get list of all albums, but if count of albums more than 24 you will not get the rest and you probably will not get profile photos album. For this you need to pass limit=0 to get albums URL.

    Here is example code:

    $tokenUrl = "https://graph.facebook.com/oauth/access_token?client_id=$yourAppId&redirect_uri=$yourRedirectUrl 
                    &client_secret=$yourAppSecret&code={$_GET["code"]}";
    
    $accessToken = file_get_contents($tokenUrl);
    
    $extAlbumUrl = "https://graph.facebook.com/me/albums?$accessToken&limit=0";
    
    $albums = json_decode(file_get_contents($extAlbumUrl)); 
    

提交回复
热议问题