2012-04-13 36 views
0

我爲粉絲頁面的iframe應用程序按鈕了,問題是,如果Facebook的它重新加載應用程序的iframe頁面,但不頂欄上如用戶點擊刷新上不同於如果用戶點擊同一位置聽衆像不像從iframe的應用

我applicatioon檢查,如果用戶是LIKEØ不喜歡轉頁扇,如果第一次不點擊Like按鈕就無法進行(類似按鈕打算在頂欄上的按鈕進行iframe的應用)

<div id="fb-root"></div> 
<script> 
window.fbAsyncInit = function() { 
FB.init({ 
    appId  : '<?php echo $app_id; ?>', // App ID 
    status  : true, // check login status 
    channelUrl : '//www. domain .it/<?php echo $sub_dir_app; ?>/cf.php', // Channel File 
    cookie  : true, // enable cookies to allow the server to access the session 
    xfbml  : true // parse XFBML 
}); 
FB.Event.subscribe('edge.remove', function(response) { 
//top.location.reload(); 
    alert('ok NOLIKE'); 
}); 
FB.Event.subscribe('edge.create', function(response) { 
//top.location.reload(); 
    alert('ok LIKE'); 
}); 
}; 
// Load the SDK Asynchronously 
(function(d){ 
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; 
if (d.getElementById(id)) {return;} 
js = d.createElement('script'); js.id = id; js.async = true; 
js.src = "//connect.facebook.net/it_IT/all.js"; 
ref.parentNode.insertBefore(js, ref); 
}(document)); 
+0

例如,你可以看到這個應用程序:https://www.facebook.com/extremesilver.gioielli/app_119909504798072,第一次點擊在LIKE上,你可以看到刷新,傳遞你點擊UNLIKE並看到iframe應用程序的刷新,在標準應用程序刷新UNLIKE不工作 – 2012-04-13 13:30:52

回答

1

使用Javascript SDK與方法'FB.Event.subscribe'。這些事件是: edge.create - 就像 edge.remove - 不像

瞭解更多: https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/

+0

我初始化FB。但是當我把FB.Event.subscribe('edge.remove',函數(響應){alert('ok NOLIKE'); });但我得到這個錯誤:未捕獲的ReferenceError:FB沒有定義 – 2012-04-13 14:05:06

+0

你需要定義FB這裏描述下的「加載」部分: https://developers.facebook.com/docs/reference/javascript/ – 2012-04-13 14:07:19

+0

我定義FB在我的應用iframe – 2012-04-13 14:17:27