单击Facebook“赞"按钮后显示内容 [英] Display content after clicking Facebook Like button

查看:98
本文介绍了单击Facebook“赞"按钮后显示内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一部分网页,我只希望人们在单击Facebook赞按钮后能够访问.

I have a section of a webpage that I only want people to be able to access after clicking a Facebook Like button.

如何隐藏该特定区域,然后仅在有人单击赞"按钮后才显示该区域.

How do I hide that particular area and then display it only after someone clicks the Like button.

至于Facebook Like代码,它看起来像这样:

As for the Facebook Like code it looks like this:

<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="www.oursite.com" show_faces="false" width="330" font="verdana"></fb:like>

<div id="hidden-area">Hidden Content</div>

推荐答案

使用'edge.create':

Use 'edge.create':

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

非常简单...甚至可以将其与jQuery结合.

really simple... can even couple it with jQuery.

<script>
    window.fbAsyncInit = function() {
        FB.init({
            appId   : '<?php echo $facebook->getAppId(); ?>',
            session : <?php echo json_encode($session); ?>, // don't refetch the session when PHP already has it
            status  : true, // check login status
            cookie  : true, // enable cookies to allow the server to access the session
            xfbml   : true // parse XFBML
        });

        // whenever the user logs in, we refresh the page
        FB.Event.subscribe('auth.login', function() {
            window.location.reload();
        });

        FB.Event.subscribe('edge.create', function(response) {
            $.get('URLlink?uid=' + <?php echo $uid; ?>, function(data) {
                $('#id').html(data);
            });
        });
    };

    (function() {
        var e = document.createElement('script');
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
    }());
</script>

这篇关于单击Facebook“赞"按钮后显示内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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