Profile Picture not found in User Object

23 views
Skip to first unread message

Brian Richardson

unread,
Oct 25, 2017, 5:55:43 PM10/25/17
to RestFB
Has anyone seen this issue? I'm probably doing it wrong, please advise.

If I run the following:


I get back:

{
   "first_name": "Brian",
   "last_name": "Richardson",
   "locale": "en_US",
   "timezone": -6,
   "gender": "male",
   "id": "1396393037145674"
}

Using:RestFB 2.0.0-rc.3

Java code:

final FacebookClient pageClient = new DefaultFacebookClient(pageAccessToken, Version.VERSION_2_9);
User user = pageClient.fetchObject(facebookUserId, User.class, Parameter.with("fields", "first_name,last_name,profile_pic,locale,timezone,gender"));

At this point user contains no profile picture info, even though it is returned in the JSON. The other fields however are populated.

Norbert Bartels

unread,
Oct 28, 2017, 5:50:30 PM10/28/17
to RestFB
Hi Brian,

sorry for the late response. 

You try to fetch a person's profile in the messenger platform context? The the User object is not suitable, and we have the PersonProfile object not yet added. The User type may work in many cases, but this only by accident :)

So you can define your own type, use a JsonObject or wait for the next release (candiate).

I opened an issue on Github (https://github.com/restfb/restfb/issues/811)

Cheers,

Norbert

Brian Richardson

unread,
Oct 30, 2017, 11:52:23 AM10/30/17
to RestFB
Norbert,

Your response was timely and perfect! I just added a new class as you suggested and it worked perfectly. I'll switch to PersonProfile when available.

Many thanks!
Brian

public class MessengerFacebookUserProfile {

@Facebook
private String id;
@Facebook("first_name")
private String firstName;
@Facebook("last_name")
private String lastName;
@Facebook
private String locale;
@Facebook
private String timezone;
@Facebook
private String gender;
@Facebook("profile_pic")
private String profilePicUrl;
Reply all
Reply to author
Forward
0 new messages