Facebook is planning to drop support for FQL after V2.0 https://developers.facebook.com/docs/apps/changelog/#v2_0_fql
The below task could be done easily with FQL
Get likes, comments and shares and all 3 combined.
Check my ans : https://stackoverflow.com/a/36997725/2439715
Improved version ( add limit(0) to removes list of likes and get only summary ):
114916098537132_1265715836790480?fields=shares,likes.limit(0).summary(true),comments.limit(0).summary(true)
"https://graph.facebook.com/v2.2/PAGEid_POSTid/?
fields=shares&access_token=YOUR_ACCESS_TOKEN";
I am using above mentioned endpoint.
Replace $pageID
and $videoID
(post id) with your variables.
"https://graph.facebook.com/v2.2/" . $pageID."_".$video->id . "/?fields=shares&access_token=YOUR_ACCESS_TOKEN";
Get comments, shares, and likes count from post:
[POST_ID]/?fields=id,shares,likes.limit(0).summary(true),comments.limit(0).summary(true)
I've included limit(0)
to prevent the API from spitting out the actual comments and likes. I believe the default limit is 25
.
Please note you can also add these fields to /feed
to get this data for all the posts on the page.
[PAGE_ID]/feed?fields=id,shares,likes.limit(0).summary(true),comments.limit(0).summary(true)
Final note: If shares
data is missing on the return, it is because the post has no shares. Instead of returning "shares": {"count": 0}
, the shares section will be removed entirely.
The field shares does not need the .summary(true)
at the end. It will bring always the total. But the likes
and comments does need .summary(true)
Example:
[POST_ID]?fields=shares,likes.summary(true),comments.summary(true)
Improved version works with Graph Api v2.11 (add limit(0) to removes lists of likes and comments and get only summary data):
[POST_ID]?fields=shares,likes.summary(true).limit(0),comments.summary(true).limit(0)
This will bring the total count of shares, comments and likes.
You may have a access_token with an read_stream
permission to get the shares count.