facebook like

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta property="fb:app_id" content="270946730017302" />
</head>
<body>
<h3>
    <div
            class="fb-like"
            data-share="true"
            data-width="450"
            data-show-faces="true" data-notify="true">
    </div>
    <div class="fb-follow" data-href="https://www.facebook.com/sherrydresses" data-layout="standard" data-size="small" data-show-faces="true" data-notify="true"></div>
</h3>
<script>
    window.fbAsyncInit = function() {
        FB.init({
            appId      : '270946730017302',
            xfbml      : true,
            version    : 'v2.9',
            status: false,
            cookie  : true,
            oauth: true
        });
        // In your JavaScript
        var auth_response_change_callback = function(response) {
            console.log("auth_response_change_callback");
            console.log(response);
//            alert(response);
        }

        var auth_status_change_callback = function(response) {
            console.log("auth_status_change_callback: " + response);
        }
        var edge_create = function(response,object) {
            console.log("edge_create: " + response+object.className);
        }
//        FB.Event.subscribe('auth.authResponseChange', auth_response_change_callback);
//        FB.Event.subscribe('auth.statusChange', auth_status_change_callback);

        FB.getLoginStatus(function(response) {
            if (response.status === 'connected') {
                // the user is logged in and has authenticated your
                // app, and response.authResponse supplies
                // the user's ID, a valid access token, a signed
                // request, and the time the access token
                // and signed request each expire
                var uid = response.authResponse.userID;
                var accessToken = response.authResponse.accessToken;
//                alert(uid);
                console.log(uid);

            } else if (response.status === 'not_authorized') {
                // the user is logged in to Facebook,
                // but has not authenticated your app
//                alert('the user is logged in to Facebook, ');
                console.log('the user is logged in to Facebook, ');


            } else {
                // the user isn't logged in to Facebook.
//                alert('the user isnt logged in to Facebook. ');
                console.log('the user isnt logged in to Facebook. ');



            }
        },true);
        FB.Event.subscribe('auth.authResponseChange', auth_response_change_callback);
        FB.Event.subscribe('auth.statusChange', auth_status_change_callback);
        FB.Event.subscribe('edge.create', edge_create);
        FB.Event.subscribe('edge.remove', edge_create);


        FB.AppEvents.logPageView();
    };

    (function(d, s, id){
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) {return;}
        js = d.createElement(s); js.id = id;
        js.src = "//connect.facebook.net/en_US/sdk.js";
//        js.src = "//connect.facebook.net/en_US/sdk/debug.js";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
</script>
</body>
</html>

https://developers.facebook.com/docs/reference/javascript/FB.Event.subscribe/v2.9
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值