0
我想在我的網站上顯示我的Facebook頁面的喜歡數量。幾天後,我以前使用的方法不再有效。撥打電話Facebook API以回覆計數不起作用
當我叫Facebook的圖形API是這樣的: https://api.facebook.com/method/links.getStats?urls=http://www.facebook.com/549585444&format=json
它給了我下面的輸出(虛構的例子):
[{"url":"http:\/\/www.facebook.com\/549585444","normalized_url":"http:\/\/www.facebook.com\/549585444","share_count":0,"like_count":122,"comment_count":0,"total_count":122,"click_count":0,"comments_fbid":null,"commentsbox_count":0}]
現在我想回應類似計數:
<?php
$fb_page = "549585444";
$url = "https://api.facebook.com/method/links.getStats?urls=http://www.facebook.com/".$fb_page."&format=json";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$json_returned = curl_exec($curl);
curl_close($curl);
$json_returned = json_decode($json_returned, true);
echo $json_returned['like_count'];
?>
但是這個數字沒有出現。任何想法爲什麼?
非常感謝,現在完美的作品。 – Stan