利用facebook的fql,取计算like次数,share次数,comment次数。
以下是php的范例:- <?php
- function facebook_shares($url){
- $fql = "SELECT url, normalized_url, share_count, like_count, comment_count, ";
- $fql .= "total_count, commentsbox_count, comments_fbid, click_count FROM ";
- $fql .= "link_stat WHERE url = '".$url."'";
-
- $apifql="https://api.facebook.com/method/fql.query?format=json&query=".urlencode($fql);
- $fb_json=file_get_contents($apifql);
- return json_decode($fb_json);
-
- }
-
- $fb = facebook_shares('http://www.freeinfo.com.my/viewthread.php?tid=1574');
- // facebook share count
- echo $fb[0]->share_count . "<br>";
-
- // facebook like count
- echo $fb[0]->like_count . "<br>";
-
- // facebook comment count
- echo $fb[0]->comment_count . "<br>";
- ?>
复制代码 |
|