Facebook登录但仍未成功

时间:2017-09-16 08:35:40

标签: javascript php android facebook facebook-graph-api

script type="text/javascript">

  function statusChangeCallback(response) {
    if (response.status === 'connected') {
      alert("Facebook Success Connected");
      testAPI();
    } else {
      alert("Facebook Not Success Connected");
    }
  }

  function onClickLogin(){ 
 window.location = "https://www.facebook.com/v2.10/dialog/oauth/?client_id=885565114939555&redirect_uri=https://www.xxx.id/this_page.php&scope=public_profile,email,user_birthday";}

  window.fbAsyncInit = function()
  FB.init({
    appId      : '885565114939555',
    cookie     : true,  
    xfbml      : true,  
    version    : 'v2.8' 
  });

  FB.getLoginStatus(function(response) {
    statusChangeCallback(response);
  });
  };

  (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_GB/sdk.js#xfbml=1&version=v2.10&appId=885565114939555";
    fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));

  function testAPI() {
    FB.api('/me', 'GET', {"fields":"id,name,email,birthday"}, function(response) {
      window.location = "https://www.xxx.id/xxx.php" + sUrl + "&name=" + response.name + "&id=" + response.id + "&email=" + response.email + "&bd=" + response.birthday;
    });
  }
/script>


<button onclick="javascript:onClickLogin();">facebok</button>
  1. 我首先打开this_page并获得弹出警报&#34; Facebook未成功连接&#34;。
  2. 点击Facebook按钮,登录Facebook登录。
  3. 在我成功登录Facebook并重定向到this_page后,我仍然获得弹出窗口警告Facebook Not Success Connected
  4. 当我在android lollipop中打开时,会发生这种情况&#34;登录到Wi-Fi网络&#34;。有什么不对吗?

1 个答案:

答案 0 :(得分:0)

console.log(response)并查看您获得的确切错误回复。

供参考,您可以尝试使用此代码https://developers.facebook.com/docs/facebook-login/web#example也许这可以让您更好地了解。