Facebook – Getting Facebooks’ Cover Photo via PHP SDK & Graph API

facebookfacebook-php-sdk

I'd like to know if there is a simple way of retrieving the Cover photo from a user in my application, via the Facebook php sdk.

I managed to retrieve the cover photo id of the album of the cover photo album, but my solution only works partially. (As you can see, it's not efficient, and If more albums will be added, and moved to other pages, thus this will not work).

    $albums = $facebook->api('/me/albums','GET');
    for($i = 0;$i<count($albums['data']);$i++){
        for($j = 0;$j<count($albums['data'][$i]);$j++){
            if($albums['data'][$i]['name'] == "Cover Photos"){
                echo $facebook->api('/me/albums/'.$albums['data'][$i]['cover_photo'],'GET');
            }
        }
    }

Best Answer

Facebook seems to have added the Cover field to User Object recently

https://graph.facebook.com/facebookuserid?fields=cover will give you the user cover pic Details

Facebook Doc Link : http://developers.facebook.com/docs/reference/api/user/

Related Topic