Reputation: 627
I am searching for this for about 2 weeks but cannot find anything. Every response about that refers to an older version of Facebook API. I can get feed of a facebook page, but I want to get like and comment counts for those posts too. I am playing with Graph Explorer but can not find any solution.
I really appreciate if anyone knows it and shares with me.
Thank you in advance!
Here my GET request:
GraphRequest g = new GraphRequest(
AccessToken.getCurrentAccessToken(),
url,
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
// my code
}
}
);
Bundle parameters = new Bundle();
parameters.putString("fields", "full_picture,message,type,source,created_time,id");
parameters.putString("limit","50");
g.setParameters(parameters);
g.executeAsync();
Upvotes: 1
Views: 2326
Reputation: 31479
You should have had a look on the docs:
A sample call would be
GET /BuzzFeed/posts?limit=1&fields=id,message,full_picture,type,source,created_time,comments.summary(true).limit(0),likes.summary(true).limit(0)
which fetches the most recent BuzzFeed
post from the page and gets the details you want:
{
"data": [
{
"id": "21898300328_10153915728380329",
"message": "🙀🙀🙀",
"full_picture": "https://scontent.xx.fbcdn.net/hphotos-xtl1/v/t1.0-9/p720x720/11951871_10153915728380329_7635044619009730855_n.jpg?oh=bcb1e2cb663815c83219edff892a9741&oe=566396B1",
"type": "photo",
"created_time": "2015-09-02T06:32:00+0000",
"likes": {
"data": [
],
"summary": {
"total_count": 4263,
"can_like": true,
"has_liked": false
}
},
"comments": {
"data": [
],
"summary": {
"order": "ranked",
"total_count": 172,
"can_comment": true
}
}
}
],
"paging": {
"previous": "https://graph.facebook.com/v2.4/21898300328/posts?fields=id,message,full_picture,type,source,created_time,comments.summary%28true%29.limit%280%29,likes.summary%28true%29.limit%280%29&limit=1&format=json&since=1441175520&access_token=&__paging_token=&__previous=1",
"next": "https://graph.facebook.com/v2.4/21898300328/posts?fields=id,message,full_picture,type,source,created_time,comments.summary%28true%29.limit%280%29,likes.summary%28true%29.limit%280%29&limit=1&format=json&access_token=&until=1441175520&__paging_token="
}
}
So, in Adroid code this would equivalent
Bundle parameters = new Bundle();
parameters.putString("fields", "id,message,full_picture,type,source,created_time,comments.summary(true).limit(0),likes.summary(true).limit(0)");
parameters.putString("limit","50");
g.setParameters(parameters);
g.executeAsync();
Upvotes: 2