简体   繁体   English

Javascript Facebook SDK登录本地

[英]Javascript facebook sdk login local

i've got this Facebook login in sdk it works fine on my server but i need to use it in local path (file://path) when user is online, but it doesn't work, i click the button without any effect this is the code 我已经在sdk中获得了这个Facebook登录名,它在我的服务器上可以正常工作,但是当用户在线时,我需要在本地路径(file:// path)中使用它,但是它不起作用,我单击按钮没有任何效果这是代码

<html>
<head>
 <link rel="stylesheet" type="text/css" href="../css/style.css">
    <meta name="viewport" content="width=320, initial-scale=0.7, user-scalable=no"> 
     <script src="JS/jquery-1.11.1.js.js"></script> 
    <link rel="stylesheet" type="text/css" href="../css/login.css">
    <script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'MYAPPID', // App ID
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      xfbml      : true  // parse XFBML
    });


    FB.Event.subscribe('auth.authResponseChange', function(response) 
    {
     if (response.status === 'connected') 
    {
         window.location.replace("gestaccount.html");
    }    
    else
    {

    }
    }); 

    };

    function Login()
    {

        FB.login(function(response) {
           if (response.authResponse) 
           {

            } else 
            {
               window.location.replace("errorconn.html");
            }
         },{scope: 'email,user_photos,publish_actions'});


    }


  // Load the SDK asynchronously
  (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));

</script>
</head>

<body style=" background: #2c3338;
  color: #606468;
  margin: 0;">

    <div id="navigation">
     <table width="100%">
                                        <tr valign="bottom">
                                            <td valign="middle" width="25%" align="center">
                                            <a href="eventi.php"><img src="IMG/icon/prvs.png" class="icons3"/></a>
                                            </td>
                                            <td valign="bottom" width="50%" align="center">
                                                <img src="IMG/LOGO-WHITE.png" class="logonbar" alt="DONUT"/>
                                            </td>
                                            <td width="25%" align="center" valign="middle">

                                            </td>
                                        </tr>
                                    </table>

                                </div>
<div id="fb-root"></div>


                              <br>
                                    <div class="containerlogin">
                                    <br><br><br><br><br>



      <div id="login" style="display: block; margin:0 auto;" >

     <img src="../IMG/LOGIN.png" class="iconlogin"  alt="" style="display: block; margin: 0 auto;"/>


              <p> <button type="submit" name="fb" onClick="Login()" class="button"> </button>


       <p style="margin-left:25px;">Loggati e avrai la possibilità di tenere controllati
                                      tutti le tue prenotazioni tra prevendite e tavoli.
                                   Inoltre se sei PR contattaci per avere accesso a tutte 
                                   le funzionalità riservate. </p>
      </div> <!-- end login -->

    </div>

                                <br>
                                <br>
                                </div>




        </div>



</body>
</html>

Thank you for answer. 谢谢你的答案。

It will only work on http or https protocols not on file:// 它仅适用于http或https协议,不适用于file://

Facebook no longer supports JS SDK calls made from a local file, the script has to be run on a file with an http:// or https:// URI. Facebook不再支持从本地文件发出的JS SDK调用,该脚本必须在具有http://或https:// URI的文件上运行。

If you want to test it locally , try running it on localhost 如果要在本地测试,请尝试在localhost上运行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM