有没有办法在< fb:like&gt被点击了? [英] Is there a way to reload the page after <fb:like> is clicked?

查看:116
本文介绍了有没有办法在< fb:like&gt被点击了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道这一点:我有一个简单的Facebook连接应用,只有在您登录后才会显示某些内容,并喜欢某个页面。
它的作品(huzzah!),但是我想通过在按下相似的按钮后自动刷新,使其更加用户友好。

I'm wondering about this: I have a simple facebook-connect app that will only show certain content after you login and liked a certain page. It works (huzzah!) but I want to make it more user friendly by making it refresh automatically after you pressed the like button.

这里有一些代码:

<?php
if ($me) {

    $pageid = -----------;
    $uid = $me['id'];

    $likeID = $facebook->api(
        array( 'method' => 'fql.query', 'query' =>
        'SELECT target_id FROM connection WHERE source_id = ' . $uid . ' AND target_id = ' . $pageid )
        );

    if ( empty($likeID) ) 
    {
        // Person is LOGGED IN, but has NOT LIKED
        echo '<script src="MY WEBPAGE"></script><fb:like href="MY WEBPAGE" layout="box_count" show_faces="false" width="450"></fb:like>';
    } 
    else
    {
        // Person is LOGGED IN, and has LIKED, score!
        echo 'Download link';
    }
}
else
{
    // Person is NOT LOGGED IN, so we know NOTHING
    echo '<script src="MY WEBPAGE"></script><fb:like href="MY WEBPAGE" layout="box_count" show_faces="false" width="450"></fb:like>';
} ?>

有什么可以做的这个代码(也许在fb:像标签?这样一来,它重新加载页面?

Is there anything I can do to this code (maybe in the fb:like tag?) that makes it reload the page after a like?

谢谢。

推荐答案

正如使用XFBML实现一样,我假设JS库( http:// connect .facebook.net / en_US / all.js#xfbml = 1 )已经加载,所以你只需要这个代码片段:

As you are using the XFBML implementation, I assume the JS library (http://connect.facebook.net/en_US/all.js#xfbml=1) is already loaded, so what you need is just this snippet:

<script>
FB.Event.subscribe('edge.create', function(response) {
    window.location.reload();
});
</script>

这篇关于有没有办法在&lt; fb:like&gt被点击了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆