简体   繁体   English

Facebook登录按钮不可见

[英]Facebook login button not visible

I've taken the facebook login button example from facebook's official example here . 我从此处的 facebook官方示例中获取了facebook登录按钮示例。 This is the code (without any change). 这是代码(无任何更改)。

<html>
<head>
  <title>My Facebook Login Page</title>
</head>
<body>
  <div id="fb-root"></div>
  <script>
    window.fbAsyncInit = function() {
      FB.init({
        appId      : '385937518116668',
        status     : true, 
        cookie     : true,
        xfbml      : true,
        oauth      : true,
      });
    };
    (function(d){
       var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
       js = d.createElement('script'); js.id = id; js.async = true;
       js.src = "//connect.facebook.net/en_US/all.js";
       d.getElementsByTagName('head')[0].appendChild(js);
     }(document));
  </script>
  <div class="fb-login-button">Login with Facebook</div>
</body>

When running this example as is, everything works fine. 按原样运行此示例时,一切正常。 However, once I remove the html, head and body I can't see the facebook login button. 但是,一旦我删除了html,head和body,就看不到facebook登录按钮。 All I see is the "Login with facebook" text. 我所看到的只是“用Facebook登录”文本。 The reason I want to remove these tags is since the page is included in another php file. 我要删除这些标签的原因是因为该页面包含在另一个php文件中。

Any ideas? 有任何想法吗?

Thanks. 谢谢。

The following worked for me: 以下为我工作:

facebookLogin.html.php facebookLogin.html.php

<html>
<head>
    <title>My Facebook Login Page</title>
</head>
<body>
<?php
    include 'fblogin.html';
?>
</body>
</html>

And the contents of the fblogin.html file are: fblogin.html文件的内容为:

<div id="fb-root"></div>
  <script>
    window.fbAsyncInit = function() {
      FB.init({
        appId      : '385937518116668',
        status     : true, 
        cookie     : true,
        xfbml      : true,
        oauth      : true,
      });
    };
    (function(d){
       var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
       js = d.createElement('script'); js.id = id; js.async = true;
       js.src = "//connect.facebook.net/en_US/all.js";
       d.getElementsByTagName('head')[0].appendChild(js);
     }(document));
  </script>
  <div class="fb-login-button">Login with Facebook</div>

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

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