<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>
答案 0 :(得分:0)
以此为参考起点:http://developers.facebook.com/docs/reference/javascript/FB.init/
首先要注意的是FB.init()调用是如何包装的:
window.fbAsyncInit = function() {
...
};
您已在init调用中将'status'设置为true,因此您应该能够订阅将返回状态值的事件,该事件将告诉您用户的登录状态。
退房:http://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/
您的FB.Event.subscribe(...)
来电也应该在同一个window.fbAsyncInit()
来电之内。
验证用户已登录后,您可以检查风扇状态。您仍然必须使用旧的REST API,因为Facebook尚未将其移植到Graph API:http://developers.facebook.com/docs/reference/rest/pages.isFan/
请注意:我们正在进行中 弃用REST API,将会 为Graph添加等效支持 此方法的API。你应该 继续使用这种方法,直到我们 在Graph API中宣布支持。
希望这能指出你正确的方向。
本教程也可能有所帮助:http://thinkdiff.net/facebook/graph-api-javascript-base-facebook-connect-tutorial/