[英]How to get the number of likes of a picture on Facebook?
I want to get the number of likes of a picture in Facebook, and show it on my websites. 我想获得在Facebook中喜欢的图片的数量,并将其显示在我的网站上。
I managed to find out the FQL query for it: 我设法找到它的FQL查询:
SELECT like_info FROM photo WHERE object_id=10152003701188306
When I tried that query at http://developers.facebook.com/tools/explorer , I get like_count = 792
. 当我在http://developers.facebook.com/tools/explorer上尝试该查询时,我得到
like_count = 792
。
I have every Facebook connect setting up and working (app id + secret key). 我有每个Facebook连接的设置和工作方式(应用程序ID +密钥)。 I've checked the debugger of my URL, and it has all meta tags needed.
我已经检查了URL的调试器,它具有所需的所有元标记。
I managed to write this code, but it gives me an empty result instead of a number. 我设法编写了这段代码,但是它给了我一个空的结果,而不是一个数字。
$result = $facebook->api(array(
'method' => 'fql.query',
'query' => 'SELECT like_info FROM photo WHERE object_id=10152003701188306'
));
echo $result['like_count'];
How can I make it work properly? 如何使它正常工作?
The array returned by FQL is pretty big and complex. FQL返回的数组很大而且很复杂。 You need:
你需要:
echo $result['data']['like_info']['like_count'];
To see everything that comes back in your query use this code: 要查看查询中返回的所有内容,请使用以下代码:
printf('<pre>%s</pre', print_r($result,TRUE) );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.