Reputation: 19
I make an iframe application for a fan page, the problem is that if user click on LIKE in top bar of facebook it reload application iframe page but dont refresh if user click on UNLIKE in same position
My applicatioon check if user is LIKE o NOT LIKE to the fan page and it cannot proceed if first dont click on LIKE button (the like button intend the button in top bar that out of iframe application)
<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));
Upvotes: 0
Views: 2895
Reputation: 14428
Use Javascript SDK with the method 'FB.Event.subscribe'
. The events are:
edge.create
- Like
edge.remove
- Unlike
Read more: https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/
Upvotes: 1