How to get profile image url from Facebook with spring-social?

facebook, java, spring, spring-social-facebook

Solution

Finally, I didn't find any mention of profile picture url in spring social My solution: Initially I planned to extend `UserOperations` (`FacebokTemplate.userOperations`) class and add new method. But it's a package-level class and doens't visible outside. So I decided to create my own template class extending `FacebookTemplate` and implement the method in this way:

public String fetchPictureUrl(String userId, ImageType imageType) {
    URI uri = URIBuilder.fromUri(GRAPH_API_URL + userId + "/picture" +
            "?type=" + imageType.toString().toLowerCase() + "&redirect=false").build();

    JsonNode response = getRestTemplate().getForObject(uri, JsonNode.class);
    return response.get("data").get("url").getTextValue();
}

Problem

I use spring-social-facebook to interact with Graph API (1.0.3.RELEASE if it's metter). And I can't find any operation to retrieve profile's image url. I found only operations which return array of bytes and they are not very convenient for the implementation. Does any kind of operation which retrieves image url exist in Spring Social? If not, is there any 'tidy' workaround for this? Thanks!

Original source

Related problems