0

I am trying to get the Page picture. However it always comes back as null. Am i doing something wrong?

FacebookClient facebookClient = new DefaultFacebookClient(accessToken)
def page = facebookClient.fetchObject(PAGE_ID, Page.class);
println page.picture //prints null

any ideas?

1

3 Answers 3

1

You need to explicitly ask for the fields you're interested (otherwise everything is null). In your case, you want the picture:

facebookClient.fetchObject(PAGE_ID, Page.class, Parameter.with("fields", "picture"));

For all fields, check official page.

0

Seems like you should have getPicture instead of picture. Also some pages require you to be logged in to retrieve that information. So you might need to authenticate with an access token.

FacebookClient facebookClient = new DefaultFacebookClient(accessToken)
def page = facebookClient.fetchObject(PAGE_ID, Page.class);
println page.getPicture //prints null
0
FacebookClient facebookClient = new DefaultFacebookClient(facebookAccessToken, Version.LATEST);

JsonObject jsonObject = facebookClient.fetchObject("/" + userId + "/picture", JsonObject.class,
        Parameter.with("type", "large"), Parameter.with("redirect", "false"));
JsonValue jsonValue = jsonObject.get("data");
JsonObject object = jsonValue.asObject();
String profileImageUrl = object.get("url").asString();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.