Question

I would like to use pictures from facebook if Gravatar does not have an image for the user on file. Can I do this through facebooks API?

Was it helpful?

Solution

Take a look at the users.getInfo API method. If a user has installed your application, or "connected" to Facebook on your site through Facebook Connect, then you have access to profile information that includes versions of their profile picture.

If you don't have a session key for the user (ie, the user hasn't installed your app or connected via Facebook Connect), you can still get the "square" profile picture, which is one of the smaller versions. You can query for this directly using the API.

The easiest way overall is probably to use the fb:profile-pic tag and XFBML. You will have to install the Facebook Connect libraries to do this, but you don't need the user to log in or anything in order to get XFBML to work... as long as you have the Javascript library on the page and an API Key to use, it will work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top