Reputation: 5703
I am creating a simple CMS system whereby users can contribute inspirational posts made by brand pages on Facebook. All the user has to do is paste in a permalink to a post and the CMS will handle pinging the Graph API in order to acquire all the info it needs. (e.g. https://www.facebook.com/photo.php?fbid=10152047553868306&set=a.99394368305.88399.40796308305&type=1&relevant_count=1)
One of the requirements of the CMS is that like
, comment
, and share
counts are included for each post. This is where I struggle.
Simply pinging the graph endpoint with a photo ID will only return a paginated list of likes/comments. There is no parameter for total likes or total comments. Fortunately, the photo
table includes like_info
and comment_info
members for me to query upon. This works great for getting totals on photos:
SELECT like_info, comment_info FROM photo WHERE object_id = 10152047553868306
One would expect then that I could apply the same FQL SELECT
on the status
or video
tables in order to get the like
and comment
info for status updates and video posts but you cannot. like_info
and comment_info
only reside on the photo
table.
At least right now I can get like/comment total for photos, but I still see no indication on how to get share totals for a photo.
Is there a way I can reliably acquire like
, comment
, and share
counts for video posts, photo posts, and status posts? Using any combination of Graph or FQL API?
Any help would be extremely appreciated.
Upvotes: 1
Views: 2176
Reputation: 31
I have found something like this for facebook graph api v2.8
$accessToken ="XXXXXXXXXX";
$fb = new Facebook\Facebook(array(
'app_id' => 'Facbook App Id',
'app_secret' => 'Facebook Secret Key',
'default_graph_version' => 'v2.8',
));
$params = array();
$request = $fb->request('GET', '/{post_id}/?fields=likes.limit(0).summary(true),comments.limit(0).summary(true)',$params,$accessToken);
$response = $fb->getClient()->sendRequest($request);
$graphNode = $response->getGraphNode();
$likeArr = $graphNode['likes']->getMetaData();
$commentArr = $graphNode['comments']->getMetaData();
echo "Total Post Likes : ".$likeArr['summary']['total_count'];
echo "Total Post Comments : ".$commentArr['summary']['total_count'];
Upvotes: 2
Reputation: 11
use this:
SELECT user_id FROM like WHERE object_id=10151751324059927 LIMIT 1000
Upvotes: 0