Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get large photo URL in one API call?

I want to display large photos in my Facebook app's feed view immediately. Is it possible to get the large photo src URL from a stream/feed using one API call? The photo id is returned in the stream/feed and one can of course then supply this photo id in an additional FQL or graph API call to retrieve all the information about that photo. However, is there a way using multi-query or batch calls to get a larger photo src url using one API roundtrip?

like image 567
John Wright Avatar asked Sep 29 '11 15:09

John Wright


3 Answers

I haven't tried this with stream/feed photos, but the generally accepted way of doing this is:

http://graph.facebook.com/{ID of object}/picture

If you want the "large" version, you would do:

http://graph.facebook.com/{ID of object}/picture?type=large

I'm not 100% sure if this would work for an actual photo (instead of a user profile picture or page profile pic), but I have a hunch it will - the only caveat is that you obviously must have a logged in user that is authorized to view the photo (unless it's public).

like image 130
streetlogics Avatar answered Sep 28 '22 19:09

streetlogics


If anybody is looking to this and type large is not enough, I found other solutions.

Type large is kind of small anyway (close to 200px). You can get larger image by adding i.e. ?width=1000 or ?height=1000. Facebook will return picture closest to given dimension and preserve aspect ratio. When passing both dimenstions like ?width=1000&height=1000, facebook will cut image to given dimensions (in this case square).

like image 25
Lucas Avatar answered Sep 28 '22 19:09

Lucas


Use Facebook UserId (Oject ID) to get the picture.

https://graph.facebook.com/173xxxx8635/picture?type=large&redirect=false

which returns JSON data with picture URL.

{
   "data": {
      "is_silhouette": false,
      "url": "https://fbcdn-profile-a.akamaihd.net/xxx/xyz/1cc066a2cae3f301d"
   }
}
like image 38
Madan Sapkota Avatar answered Sep 28 '22 17:09

Madan Sapkota