2012-04-13 32 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