views:

216

answers:

2

Hey! 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)?

+3  A: 

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/&lt;UID&gt;/picture"&gt; - 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), you can view what's inside user table here.

serg
Tired fool I was indeed; thanks serg!
Morten Bergfall
+1  A: 

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

http://graph.facebook.com/&lt;UID&gt;/picture?type=large
Beiru