How to get full-size profile picture of User?

3,409 views
Skip to first unread message

narenlog

unread,
Sep 2, 2010, 3:19:09 PM9/2/10
to RestFB
Hi
User.getPicture() returns a very small size version of the user's
profile picture.
-----
User user = facebookClient.fetchObject("me", User.class,
Parameter.with("fields", "id, name,
picture"));
-----

I want to get the full-size profile photo of a user. The below does
not work in code because Facebook is redirecting to another URL to
display the final image. I was thinking more along the lines of
mapping any JSON returned to "Photo" and then calling "getSource()" on
it so I can read it myself.
-----
Photo profilePhoto = facebookClient.fetchObject("me/picture",
Photo.class);
-----

So I wrote an FQL query. Anyone have a better idea?
-----
String query = "SELECT name,pic_big FROM user WHERE uid=12345";
List<User> users = facebookClient.executeQuery(query, User.class);
-----

revetkn

unread,
Sep 2, 2010, 3:22:33 PM9/2/10
to RestFB
User.getPicture() is being removed in 1.6. The Graph API has changed
and constructing URLs manually (no need for RestFB) is the correct way
to do this going forward. See http://developers.facebook.com/docs/api#pictures

For example:
http://graph.facebook.com/btaylor/picture?type=large

Thanks
Mark

narenlog

unread,
Sep 2, 2010, 4:37:27 PM9/2/10
to RestFB
Thanks Mark!
For others who may stumble on the question, when you call this URL
directly, facebook redirects to the actual image location.
So I used HttpUrlConnection to "GET" the url, read the URL stream so
the redirect happens and then grabbed the actual image location post-
direct via HttpUrlConnection.getURL()

See:
http://stackoverflow.com/questions/3341672/getting-the-real-facebook-profile-picture-url-from-graph-api

On Sep 2, 3:22 pm, revetkn <mark.a.al...@gmail.com> wrote:
> User.getPicture() is being removed in 1.6.  The Graph API has changed
> and constructing URLs manually (no need for RestFB) is the correct way
> to do this going forward.  Seehttp://developers.facebook.com/docs/api#pictures
Reply all
Reply to author
Forward
0 new messages