2011-05-17 76 views
1
<script type="text/javascript"> 
     window.fbAsyncInit = function() { 
      FB.init({appId: '197724456937488', status: true, cookie: true, xfbml: true}); 

      // this will fire when any of the like widgets are "liked" by the user 
FB.Event.subscribe('edge.create', function(response) { 

     document.getElementById('likepost').style.display = ""; 
      document.getElementById('falsebox').style.display = "none"; 
       document.getElementById('fb').style.display = ""; 

}); 

FB.Event.subscribe('edge.remove', function(response) { 
    console.log('This was UNliked from this page: ' + window.location); 
}); 
     }; 
     (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> 

    <div id="fb" style="display:none">  
    <fb:like-box href="<?php echo $detail['Post_FB'] ;?>" width="292" height="100" show_faces="false" stream="false" header="false"></fb:like-box> 
    </div> 
    <div id="link" style="display:none"> 
    <fb:like href="http://design-pro.co.cc/appleworld/post.php?id=<?php echo $id?>" send="false" width="450" show_faces="true" font=""></fb:like>  
    </div> 

Facebook的檢查IsFan不能正常工作,請幫助

回答

0

以此爲起點以供參考:http://developers.facebook.com/docs/reference/javascript/FB.init/

注意到的第一件事是FB.init()調用是如何在包裹:

window.fbAsyncInit = function() { 
    ... 
}; 

您已經設置您的通話初始化「狀態」爲真,所以你應該能夠訂閱的盛會,返回狀態值,告訴你用戶的登錄狀態。

退房:http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/

FB.Event.subscribe(...)調用也應該是相同的window.fbAsyncInit()調用中。

確認用戶已登錄後,您可以檢查風扇狀態。你仍然需要使用舊的REST API,因爲Facebook已經沒有這個移植到圖形API:http://developers.facebook.com/docs/reference/rest/pages.isFan/

請注意:我們是在 自嘲的REST API的過程中,會加入 相當於支持此方法的圖表 API。您應該繼續使用此方法 ,直到我們 宣佈支持Graph API。

希望這點能指出您的方向是正確的。

本教程可能也有幫助:http://thinkdiff.net/facebook/graph-api-javascript-base-facebook-connect-tutorial/

+0

謝謝。我修改了代碼,它可以在某些Facebook帳戶上正確檢測到isfan,但是我的一些朋友Facebook帳戶返回了「isfans」,即使他們不喜歡該頁面。你知道爲什麼嗎? – Clasher 2011-05-18 07:14:58