开发者

Refresh after Facebook like is clicked

开发者 https://www.devze.com 2023-02-01 01:34 出处:网络
am trying to build a facebook canvas app (iframe). To the head section we hav开发者_开发技巧e xfbml like (FB:like)

am trying to build a facebook canvas app (iframe). To the head section we hav开发者_开发技巧e xfbml like (FB:like) Mid way thru the page we have an FQL call to see if the user has like a particular fan page or not (this app is linked directly from a fan page) If the user has already liked the page they get to see X content, if not they get to see Y content - That part if working fine - the part I am struggling with is to get the page to automatically refresh after the user clicks like so they get to see X content. If they do a manual refresh that works So, have tried adding a java event subscribe which I guess monitors the page for an onclick scenario.....

This kind of works, but I get a firefox pop up asking to resend data before the page will refresh.

The current app page is: apps.facebook.com/marqueenightclub/ The workflow we are trying to emulate is similar to this L'oreal app: apps.facebook.com/menexpertwhiteactiv/ prior to clicking like content user seesY content, clicking like then triggers the X content

Any help appreciated - regards Tony


If you want to do a full page refresh, eg. if you're doing something with a server-side SDK, you can use the following code:

FB.Event.subscribe('edge.create', function(response) {
      top.location.href = "http://www.facebook.com/yourpagename/app_yourappid"
});

You'll basically just have to hard code in your app's url on facebook. This is because window.reload() wont work, and neither will top.location.href = top.location.href.


If you are using the Javascript SDK you should be able to subscribe to the edge.create action, for example:

FB.Event.subscribe('edge.create',
    function(response) {
        // Do something here
    }
);

See https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/

Within you function ('Do something here' above) you'll want to fire off an ajax request to fetch your data and replace what's currently in the DOM with what you want (or call window.location = 'your URL', but that will do a full page refresh)

0

精彩评论

暂无评论...
验证码 换一张
取 消