JavaScript   发布时间:2022-04-16  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了javascript – Facebook登录未在Safari / iPhone中打开大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

我正在创建一个显示Facebook好友的应用程序.首先,用户需要点击登录按钮,然后在填写登录ID和密码后会出现一个简单的弹出屏幕,它会显示好友列表.
一切正常,可在Firefox,Chrome,IE上运行但不会在Safari和iPhone中打开弹出窗口.
有人建议我在channelUrl中添加域名和频道名称.我创建了一个channel.html并添加引用,但它没有帮助我.
我搜索了很多,但没有找到帮助.

这是我的代码.
Custom.js

function getUser()
{
FB.init({
    appId      : '289403314507596',// App ID
    channelUrl : 'http://bc2-236-161.compute-1.amazonaws.com/html/channel.html',// Channel File
    status     : true,// check login status
    cookie     : true,// enable cookies to allow the server to access the session
    xfbml      : true  // parse XFBML
});

 (function(d){
 var js,id = 'facebook-jssdk',ref = d.getElementsByTagName('script')[0];
 if (d.getElementById(id)) {return;}
 js = d.createElement('script'); js.id = id; js.async = true;
 js.src = "//connect.facebook.net/en_US/all.js";
 ref.parentNode.insertBefore(js,ref);
 }(document));

//check current user login status
FB.getLoginStatus(function(response) {
    if (response.status === 'connected') {
        window.location="facebook_friend.html"
        loadFriends();
    } else {
        //user is not connected.
        FB.login(function(response) {
            if (response.authResponse) {
                window.location="facebook_friend.html"
                loadFriends();
            } else {
                alert('User cancelled login or did not fully authorize.');
            }
        });
    }
 });
 }
//start from here
 $(document).ready(function(){
$('.load-button').click(function(){
    getUser();
});
});   

channel.html