2012-05-11 30 views
1

我正在努力爲我的網站編寫一個簡單的應用程序,並努力爭取1分。

Facebook頁面有;

$pageID = 'dorimedia'; 

什麼是一個網站是平等的?我想獲得顯示外部網站「喜歡」多少次的價值。

謝謝! 亞當

+0

我想有一個滑動條來顯示實際網站的數量。這是我的例子,在我的網站上(在頁腳中)www.dorimedia.co.nz – Adam

+0

我能以某種方式使用get_file_content命令從這裏獲取細節嗎? https://api.facebook.com/method/fql.query?query=select%20%20like_count,%20total_count,%20share_count,%20click_count%20from%20link_stat%20where%20url=%22http://www.dori。 co.nz/%22 – Adam

回答

0

沒什麼。 您可以像完整路線一樣使用域名或域名+路徑,但本身不能使用短ID。

如果你需要的東西更短,而不是由你一定可讀,你可以散列,或採用一些加密算法完整的網址獲得更短的id,請嘗試查看md5,sha1hash方法(假設您使用php)

UPDATE 如果你需要的是有多少的Facebook就像是一個網站都有,有這種直接從谷歌認爲是這樣的API:

http://api.facebook.com/restserver.php?method=links.getStats&urls=www.google.com 

這導致包括註釋的XML響應,喜歡和其他有趣的信息。谷歌,例如有以下回應:

<links_getStats_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true"> 
    <link_stat> 
     <url>www.google.com</url> 
     <normalized_url>http://www.google.com/</normalized_url> 
     <share_count>2095550</share_count> 
     <like_count>795778</like_count> 
     <comment_count>705595</comment_count> 
     <total_count>3596923</total_count> 
     <click_count>265614</click_count> 
     <comments_fbid>381702034999</comments_fbid> 
     <commentsbox_count>307</commentsbox_count> 
    </link_stat> 
</links_getStats_response> 

那麼它提取從XML的信息,很容易夠像這樣的問題:

$url = "http://api.facebook.com/restserver.php?method=links.getStats&urls=".urlencode($source_url); 
$xml = file_get_contents($url); 
$xml = simplexml_load_string($xml); 
$shares = $xml->link_stat->share_count; 
$likes = $xml->link_stat->like_count; 
$comments = $xml->link_stat->comment_count; 
$total = $xml->link_stat->total_count; 
$max = max($shares,$likes,$comments); 

Click here for the Source

+0

我嘗試了一堆不同格式的網址,似乎沒有工作。我正在嘗試使用滑動條來顯示實際網站的數量。這是我的例子,在我的網站(在頁腳)www.dorimedia.co.nz。謝謝 – Adam

+0

查看更新瞭解更多信息 –

+0

你是我的朋友!謝謝!! – Adam