2

Have gotten the foundation in place, but now, finding myself wanting to play around with my
application's user's profile pictures; I'm stumped....and have been for quite some hours...

Firstly, my oauth_token / access_token is obtained, using the official (though Alpha ;-)
Facebook C# SDK and only utilize the Graph API.

FBapi.Get("/" + friend.Dictionary["id"].String + "/picture");

leads to an exception due to not returning a JSONObject, and

using the complete http://graph.facebook.com/me/picture is forwarded/translated to the image's URL.

Trying a more direct approach didn't pan out either :

WebClient wcImg = new WebClient();

wcImg.DownloadFile("/" + friend.Dictionary["id"].String + "/picture", "name_blame.jpg");

Some details are lacking in my question; I beg your pardon, am very tired and will edit later if uproar commences.

Ideas?


Addendum : Boy, afflicted by code blindness I was indeed! However, your sensibility gave me what I needed (Zynga, tremble in my canvas ;-).

For sake of curiosity...it appears there's no JSON template(pardon my lack of lingo) available for profile pictures? Then how do one go about obtaining a fleshed out, Graph API Photo of that profile picture (if available)?

Morten Bergfall
  • 2,296
  • 4
  • 20
  • 35

3 Answers3

4

The picture in Graph API is a bit special animal. It doesn't return json, it directly forwards to the image. It was made so that you can use this url right in html:

<img src="http://graph.facebook.com/<UID>/picture"> - displays avatar

Now if you need to know actual picture URL it redirects to there are 2 options:

  1. Read redirect headers from that graph URL.
  2. Use FQL:

    select pic_square from user where uid=12345
    

There is alot of other info that can be extracted about a user using FQL (including pictures in other sizes).

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
serg
  • 109,619
  • 77
  • 317
  • 330
3

Also, if You want to show big profile photo, use this:

http://graph.facebook.com/<UID>/picture?type=large
Beiru
  • 312
  • 5
  • 13
  • This isn't working for me to get anything bigger than a large thumbnail. Do you how to get the source photo for the user's profile pic? – John Wright Mar 04 '12 at 15:21
1

You can get ALL friends' profile pictures (direct Links to the photos), in a single GET request:

https://graph.facebook.com/me/friends?access_token=[oauth_token]&fields=name,id,picture

Then use Json to Decode the string.. and that's all...

NJoy ^_^

darki699
  • 441
  • 4
  • 2