我想获得指定网址的数量。
/http://graph.facebook.com/http://www.example.com
但是,如果URL如下所示,则会出现问题:
/http://www.example.com/page.php?param1=aaa¶m2=bbb
然后Facebook将其视为:
/http://www.example.com/page.php
我尝试使用urlencode(),但后来我得错了号码,因为对于Facebook网址:
/http://www.example.com/page.php
和
/http://www.example.com/page.php?sort=by_date
是两个不同的页面。
另一方面,我无法删除所有GET,因为它们有时很重要,例如
/http://www.example.com/?article=123
这种情况有解决方案吗?
答案 0 :(得分:0)
您可以通过输入like按钮的URL轻松解决此问题。你需要做的就是构建url然后传递它。这是一个php示例:
$mainURL = "http://www.example.com/";
$articleID = $r['id']; // GET THE ARTICLE ID FROM DB OR SOMETHING
$finalURL = $mainURL . "?article=" . $articleID;
// here you can wget the facebook api and see the number of likes etc using $finalURL
答案 1 :(得分:0)
使用此Facebook API方法
https://api.facebook.com/method/fql.query?query=select total_count,like_count,comment_count,share_count,click_count from link_stat where url='http://www.google.com/'&format=json
结果:
[{"total_count":5328613,"like_count":934962,"comment_count":969801,"share_count":3423850,"click_count":265614}]
。
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $call);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);
return json_decode($output);
}
$fb_likes = reset( get_fb_likes("http://www.cnn.com") );
echo $fb_likes->total_count;
echo $fb_likes->like_count;
echo $fb_likes->comment_count;
echo $fb_likes->share_count;
echo $fb_likes->click_count;
?>
通过http://halgatewood.com/get-number-of-facebook-likes-for-a-url/