Facebook登录屏蔽了一个框架问题 [英] facebook login blocked a frame issue

查看:91
本文介绍了Facebook登录屏蔽了一个框架问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意
我阅读了有关此问题的所有相关问题,但无法找到解决问题的解决方案。

NOTE I read all the related questions regarding this issue but i couldn't find a solution for my problem.

Facebook登录API HTTPS问题

Facebook:不安全的JavaScript问题(document.domain值应该是相同的)

我正面临被阻止的框架facebook api问题:

I'm facing the blocked frame facebook api issue:

Blocked a frame with origin "https://www.facebook.com" from accessing a frame with origin "http://static.ak.facebook.com".  The frame requesting access has a protocol of "https", the frame being accessed has a protocol of "http". Protocols must match.

我跟随了facebook api教程,我正在使用这段代码。

i followed the facebook api tutorial and i'm using this code.

     window.fbAsyncInit = function() {
        FB.init({
          appId      : 'appID',
          status     : true,
          channelUrl : 'http://staging.mywebsite.com/login/channel',
          cookie     : true,
          xfbml      : true 
        });

        FB.login(function(response) {
            if (response.authResponse) {
                console.log('done');
            } else {
                console.log('problem');
            }
        });

        FB.Event.subscribe('auth.login', function(response) {
            console.log('test reponse');
            console.log(response);

        }); 
      };

      (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));

/ login / channel包含:

/login/channel contains:

     $cache_expire = 60*60*24*365;
     header("Pragma: public");
     header("Cache-Control: max-age=".$cache_expire);
     header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$cache_expire) . ' GMT');
     echo '<script src="//connect.facebook.net/en_US/all.js"></script>';

fb登录按钮:

     <fb:login-button width="200" max-rows="1" scope="email,user_birthday,user_interests,user_likes,user_location,user_hometown,user_mobile_phone,user_address"></fb:login-button>

我也尝试过,但没有解决问题:

I tried this too but it didn't fix the problem:

      channelUrl : '//staging.mywebsite.com/login/channel', //same issue

我想念什么吗?或者我应该在fb应用程序设置中更改某些内容?

did i miss anything ? or maybe i should change something in the fb app settings?

推荐答案

看起来您可能需要修改以下代码才能浏览https

It looks like you might need to modify the code below to go over https

(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 = "https://connect.facebook.net/en_US/all.js";
     ref.parentNode.insertBefore(js, ref);
   }(document));

此外,src =// domain.com将继承协议,您可以尝试: p>

Also, src="//domain.com will inherit the protocol. You could try:

echo '<script src="https://connect.facebook.net/en_US/all.js"></script>';

这篇关于Facebook登录屏蔽了一个框架问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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