facebook4j post from is null

917 views Asked by At

I am using the Facebook API from Java with Facebook4j.

I have two servers, on the one that uses Facebook 2.3 API when I get the from of a post,

Post post = connection.getFeed().get(0);
post.getFrom();

I get the user, but in the server that uses Facebook 2.4 API, the from is null.

Any idea? I don't see any documented change in the fb API.

1

There are 1 answers

1
heenenee On BEST ANSWER

As described in the Facebook Platform Changelog, as of v2.4, you now have to manually specify fields if you want them to be retrieved:

To try to improve performance on mobile networks, Nodes and Edges in v2.4 requires that you explicitly request the field(s) you need for your GET requests. For example, GET /v2.4/me/feed no longer includes likes and comments by default, but GET /v2.4/me/feed?fields=comments,likes will return the data. For more details see the docs on how to request specific fields.

According to the docs on Post, the relevant field is named from. To request this field in the me feed using Facebook4J, you can use a Reading object, as follows:

facebook.getFeed(new Reading().fields("from"))