2010-11-29 54 views
1

我有幾個Facebook像按鈕在自己正在通過XFBML呈現。點擊它們後,它們似乎工作,他們從標準的按鈕變成了「豎起大拇指」圖標,上面寫着「你喜歡這個」。然而,在一兩秒之後(我假設擊中FB的服務器並回來)需要一段時間,它會自動取消自己的注意力,然後轉回原來的按鈕。Facebook喜歡的按鈕自動撤消自己

See a video of what I mean here.

我的代碼是非常標準:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" lang="en"> 

... 

<fb:like href="http://www.example.com/valid/path" layout="button_count" ref="recipe_preview" /> 

... 

<script type="text/javascript"> 
    window.fbAsyncInitExt = function() { 
     FB.Event.subscribe('edge.create', function(response) { 
      alert('Facebook Like Button: ' + response); 
     }); 
    }; 
</script> 

... 

<div id="fb-root"></div> 
<script type="text/javascript"> 
    window.fbAsyncInit = function() { 
     FB.init({ 
      appId: 'XXXXXXXXXX', // my app ID is here 
      status: true, 
      cookie: true, 
      xfbml: true 
     }); 
     if (typeof(fbAsyncInitExt) == 'function') { 
      fbAsyncInitExt(); 
     } 
    }; 
    (function() { 
     var e = document.createElement('script'); 
     e.type = 'text/javascript'; 
     e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; 
     e.async = true; 
     document.getElementById('fb-root').appendChild(e); 
    })(); 
</script> 

編輯:對於它的價值,我也試圖看看如果Facebook被髮送任何日誌信息,但它並沒有出現成爲:

<script type="text/javascript"> 
    window.fbAsyncInitExt = function() { 
     FB.Event.subscribe('edge.create', function(response) { 
      alert('Facebook Like Button: ' + response); 
      console.debug(response); 
     }); 
     FB.Event.subscribe('fb.log', function(response) { 
      alert('LOG: ' + response); 
      console.debug(response); 
     }); 
    }; 
</script> 

回答

4

經過大量的挖掘,我終於發現了錯誤的根源。事實證明,我的fb:like標記中的href值所引用的頁面至少需要HEAD中的fb:app_idfb:admins META標記中的一個。作爲參考:http://developers.facebook.com/docs/opengraph

+0

你是opengraph docs的頁面解決了我的問題,謝謝:) – 2011-06-16 23:04:59

0

在嘗試了所有我能找到的解決方案後,沒有任何工作,但是當您從Facebook上獲取代碼時,我嘗試使用「Live feed」應用ID而不是默認的「實時流」開發人員頁面,這爲我工作。