Auto refresh timeline page when like button pressed on application?

谁说胖子不能爱 提交于 2019-12-07 09:03:35

问题


Before timeline was published on pages, when a user pressed the like button on a page, the page refreshed by itself.

Now with the timeline enabled if you are to the application and press the right top like button, the page does not refresh by it self and the application does not recognize that the user "liked" the page.

Is there a way or an event on how to refresh the page automatically when the user presses the like button?

Thanks.


回答1:


A bug have been filed at FB, check it out and subscribe at https://developers.facebook.com/bugs/228778937218386




回答2:


You could periodically check if the user liked the page like so:

FB.api
(
    "/me/likes/[page id]",
    function( response )
    {
        if ( response.data )
        {
            if( response.data.name )
            {
                alert( "We've got a fan!" );
            }
            else
            {
                alert( "Not a fan!" );
            }
        }
        else
        {
            alert( "Something went worng..." );
        }
    }
);

Also, if you need to move the user to another tab/app you will have to refresh the whole page so use:

top.location.href = "[new url]";



回答3:


I managed to do a workaround to detect if the page is still not using timeline by looking for an album called "Cover Photos" on the album list of that page. This way you can still show fangates to those pages.

Here's a sample:

http://graph.facebook.com/-page_id-/albums?fields=name

You don't need a token unless the page isn't published yet.

The problem with this approach is that some pages still don't have cover picture yet, but it's the minority.




回答4:


Try this:

FB.Event.subscribe('edge.create',function(){
    window.location = '/some/awesome/url';
});


来源:https://stackoverflow.com/questions/9509173/auto-refresh-timeline-page-when-like-button-pressed-on-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!