6

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?

Kara
  • 6,115
  • 16
  • 50
  • 57
cch
  • 3,336
  • 8
  • 33
  • 61

1 Answers1

3

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'] ?> />
phwd
  • 19,975
  • 5
  • 50
  • 78
  • When I try to add the photoid at the end of graph.facebook.com/here it returns false. Any suggestions? – cch May 22 '12 at 18:45
  • @cchacholiades if it's false you don't have access to it. You need a valid access token with the proper permissions. – phwd May 22 '12 at 19:01
  • The permissions I am asking for are those $url = $facebook->getLoginUrl(array('req_perms' => "user_photos, friends_photos, publish_stream", 'fbconnect' => 0, 'canvas'=>1)); – cch May 22 '12 at 19:16
  • @cchacholiades what happens when you call $facebook->api('/thephotoid') – phwd May 22 '12 at 19:19
  • I have done this $new = $facebook->api('/thephotoid'); and echo $new And it just prints the word array – cch May 22 '12 at 19:25
  • @cchacholiades It's a JSON response. So echoing the response will give you an array. You need to parse the response. – phwd May 22 '12 at 20:29