2017-07-25 58 views
-2

以前通過Facebook登錄工作正常,沒有任何問題。使用JavaScript登錄Facebook SDK在PHP codeigniter網站上實現。但在2017年7月更新後,我無法通過Facebook登錄網站。通過Facebook登錄停止工作後,應用程序2017年7月更新

以下是我的code.Kindly援助。

<script type="text/javascript" defer="defer"> 
      window.fbAsyncInit = function() { 
      FB.init({ 
      appId: "<?php echo $global['facebook_app_id']; ?>", // App ID 
      channelUrl: "<?php echo base_url(); ?>channel.html", // Channel File 
      status: true, // check login status 
      cookie: true, // enable cookies to allow the server to access the session 
      picture: "http://www.fbrell.com/f8.jpg", 
      xfbml: true // parse XFBML 
      }); 
      }; 
      // 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> 



       function loginMe(path) 
      { 
       var params1 = ''; 
       FB.login(function (response) { 
        if (response.authResponse) { 
         console.log('Welcome! Fetching your information.... '); 
         FB.api('/me', function (response) { 
          var params = "username=" + response.username + "&first_name=" + response.first_name + "&last_name=" + response.last_name + "&email=" + response.email + "&fb_id=" + response.id + "&gender=" + response.gender + "&birthday=" + response.birthday + "&action_type=fb_login"; 
          //var params="email="+response.email; 
          FB.api('/me/friends', function (response) { 
           //         alert(JSON.stringify(response)); 
           var i = 0; 
           $.each(response.data, function (key, val) { 
            i++; 
           }); 
           params1 = "&facebook_friend_count=" + i; 
          }); 
          if (typeof (response.email) === "undefined") { 
           alert('Sorry, there is technical problem to fetch data from facebook, please try again.'); 
           window.parent.location = path; 
          } 
          jQuery.ajax({ 
           type: 'post', 
           url: path + 'login-with-facebook', 
           data: params, 
           success: function (msg) { 
            if (msg != '' && msg != 'fail') { 
             window.location.href = path + "login-with-fb/" + msg; 
            } 
            else 
            { 
             if (msg == 'fail') 
              alert('Sorry, there is technical problem to fetch data from facebook, please try again.'); 
             window.parent.location = path; 
            } 
           } 
          }); 
         }); 

        } else { 
         //console.log('User cancelled login or did not fully authorize.'); 
        } 
       }, {"scope": "email,read_stream"}); 
      }    

輸入登錄憑據我收到警報後,每次「對不起,是技術問題從Facebook獲取數據,請稍後再試。」我無法從Facebook獲取用戶詳細信息。

+0

有沒有權限命名'read_stream' – WizKid

+0

現在什麼是另類的read_stream? –

+0

Facebook經常棄用其API版本。例如,[版本2.3已於2017年7月8日棄用](https://developers.facebook.com/docs/apps/changelog)。確保保持最新(這可能意味着更新庫)。 – Chris

回答

0

Version 2.3 of the Facebook API was deprecated on July 8, 2017。更新您的配置代碼以使用更高版本,並確保一切仍然有效。您應該也可以查看upgrade guide中的更改。

這裏是the documentation配置示例:

window.fbAsyncInit = function() { 
    FB.init({ 
    appId   : 'your-app-id', 
    autoLogAppEvents : true, 
    xfbml   : true, 
    version   : 'v2.10' // <-- Right here 
    }); 
    FB.AppEvents.logPageView(); 
}; 
+0

根據升級指南嘗試進行更改。仍然遇到同樣的問題。 –

+0

您是否按照我在答案中顯示的那樣更改'version'值? – Chris

+0

請編輯你的問題,並在那裏添加你的代碼。您可以選擇它並按下Ctrl + K或單擊「{}」按鈕進行正確格式化。 – Chris

相關問題