当使用facebook登录api时,javascript代码的响应是什么?

当使用facebook登录api时,javascript代码的响应是什么?,javascript,facebook,api,authentication,Javascript,Facebook,Api,Authentication,大家好,我刚刚学习了javascript,我正在尝试在创建网页的过程中使用Facebook登录api创建一个登录函数 因此,我试图通过查看登录api的文档来理解代码的含义,但有一点我不明白 <!DOCTYPE html> <html> <head> <title>Facebook Login JavaScript Example</title> <meta charset="UTF-8"> </he

大家好,我刚刚学习了javascript,我正在尝试在创建网页的过程中使用Facebook登录api创建一个登录函数

因此,我试图通过查看登录api的文档来理解代码的含义,但有一点我不明白

<!DOCTYPE html>
<html>
<head>
<title>Facebook Login JavaScript Example</title>
<meta charset="UTF-8">
</head>
<body>
<script>

  function statusChangeCallback(response) {  // Called with the results from FB.getLoginStatus().
    console.log('statusChangeCallback');
    console.log(response);                   // The current login status of the person.
    if (response.status === 'connected') {   // Logged into your webpage and Facebook.
      testAPI();  
    } else {                                 // Not logged into your webpage or we are unable to tell.
      document.getElementById('status').innerHTML = 'Please log ' +
        'into this webpage.';
    }
  }


  function checkLoginState() {               // Called when a person is finished with the Login Button.
    FB.getLoginStatus(function(response) {   // See the onlogin handler
      statusChangeCallback(response);
    });
  }


  window.fbAsyncInit = function() {
    FB.init({
      appId      : '{app-id}',
      cookie     : true,                     // Enable cookies to allow the server to access the session.
      xfbml      : true,                     // Parse social plugins on this webpage.
      version    : '{api-version}'           // Use this Graph API version for this call.
    });


    FB.getLoginStatus(function(response) {   // Called after the JS SDK has been initialized.
      statusChangeCallback(response);        // Returns the login status.
    });
  };
 
  function testAPI() {                      // Testing Graph API after login.  See statusChangeCallback() for when this call is made.
    console.log('Welcome!  Fetching your information.... ');
    FB.api('/me', function(response) {
      console.log('Successful login for: ' + response.name);
      document.getElementById('status').innerHTML =
        'Thanks for logging in, ' + response.name + '!';
    });
  }

</script>


<!-- The JS SDK Login Button -->

<fb:login-button scope="public_profile,email" onlogin="checkLoginState();">
</fb:login-button>

<div id="status">
</div>

<!-- Load the JS SDK asynchronously -->
<script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js"></script>
</body>
</html>
但我不知道“反应”从何而来。结果与任何其他字符相同,而不是响应

当我搜索javascript函数时,我不明白为什么需要响应以及它是如何工作的,所以我留下了一个问题。如果你能告诉我,我会非常感激的。
感谢您阅读这篇长篇文章,祝您度过愉快的一天

FB.api
在后台与api通信,然后将结果传递回回调函数
response
在这里只是一个参数名,您可以在该位置使用任何其他您喜欢的参数名。
FB.api
在后台与api通信,然后将结果传递回回调函数
response
在这里只是一个参数名,您可以在该位置使用您喜欢的任何其他参数名。
function testAPI() {                      // Testing Graph API after login.  See statusChangeCallback() for when this call is made.
    console.log('Welcome!  Fetching your information.... ');
    FB.api('/me', function(response) {
      console.log('Successful login for: ' + response.name);
      document.getElementById('status').innerHTML =
        'Thanks for logging in, ' + response.name + '!';
    });
  }