spring-attic / spring-social-facebook

Facebook API binding and connect support.
http://projects.spring.io/spring-social-facebook
Apache License 2.0
248 stars 269 forks source link

Allow nested request in facebook API #199

Open robertobsc opened 8 years ago

robertobsc commented 8 years ago

This issue is registered as well at jira: https://jira.spring.io/browse/SOCIALFB-200

Facebook Graph allows nested requests for any request.

GET graph.facebook.com
  /{node-id}?
    fields=<first-level>{<second-level>}

This opperation cant be done with spring social. For instance, when i try to get all posts from an user with it respectively likes. There's no space in API to bind extra nested request:

getConnection().getApi().feedOperations().getPosts(pageParams);

I also can't use the fetchConnections from FacebookTemplate because an exception is thrown when retrieving nested objects. For example, the code:

        PagedList<FacebookPost> posts = 
                getConnection().getApi().fetchConnections("me", "posts", FacebookPost.class, 
                        "likes," + Arrays.asList(IPost.ALL_POST_FIELDS).stream().collect(Collectors.joining(",")));

Generates this exception:

com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token
 at [Source: java.io.StringReader@3765712c; line: 1, column: 2612] (through reference chain: java.util.ArrayList[1]->com.roberto.social.domain.FacebookPost["likes"])