Search code examples
facebookfacebook-graph-apifacebook-php-sdkphotos

Display Facebook image source by id


I am developing a Facebook application that stores into MySQL the photo[id]. I am using Facebook's Graph API to retrieve all of the user's photos and by a radio button the selected photo[id] is stored into mysql.

The problem is, how should I display the image's source by the id stored?


Solution

  • You inspect the Graph Object for that id,

    graph.facebook.com/photoID
    

    For example a photo from facebook.com/facebook

    http://graph.facebook.com/427100966728
    

    This will return a JSON response for which you can choose the size you desire for the source.

    For more information see, http://developers.facebook.com/docs/reference/api/photo/

    For example in the PHP SDK

    $a_photo = $facebook->api('/427100966728');
    
    <img src=<?php echo $a_photo['picture'] ?> />