使用facebook登录后如何获取个人资料图片路径

How to get the profilepic path after login with facebook

这里我正在使用 facebook 登录,而且它工作正常,现在我的问题是登录后我需要个人资料图片路径,我不知道如何获得路径,如果有人知道请更新你的 answer.as od 现在我得到像 id,name,email 这样的值,但我不知道 profilepic path

window.fbAsyncInit = function() {
          FB.init({appId: '1990039811315283', status: true, cookie: true, xfbml: true});

      };
      (function() {
        var e = document.createElement('script'); e.async = true;
        e.src = document.location.protocol +
          '//connect.facebook.net/en_US/all.js';
        document.getElementById('fb-root').appendChild(e);
      }());

    function fetchUserDetail()
    {
      FB.api('/me?fields=id,name,email', function(responseFromFB){ 
                //console.log("Name: "+ response.name + "\Email: "+ response.email + "ID: "+response.id);
    console.log(JSON.stringify(responseFromFB)); 
     var userName = responseFromFB.name;
    var userEmail = responseFromFB.email;
    var profilePic = '1.png';
    var registerFrom = 'Web';
    var FCM_Token = '';
      $.ajax({
     url:'admin/rest/registerFB',
     type:'POST',
     data: {userName: userName, userEmail: userEmail, profilePic: profilePic, registerFrom: registerFrom, FCM_Token: FCM_Token},
     success:function(loginResponse){
        if(loginResponse['status']=='success'){
        window.location.href = "index.php";
        } 
       
     },
    }); 
            });
   
   
    }

    function checkFacebookLogin() 
    {
        FB.getLoginStatus(function(response) {
          if (response.status === 'connected') {
            fetchUserDetail();
          } 
          else 
          {
            initiateFBLogin();
          }
         });
    }

    function initiateFBLogin()
    {

     
      FB.login(function(response) {
    fetchUserDetail();
   }, {scope: 'email'});
    }
<html>
<head>
<title>Facebook Login JavaScript Example</title>
<meta charset="UTF-8">
</head>
<body>
  <input type="button" class="btn btn-lg btn-fb" value="Sign in using Facebook" scope="public_profile,email" onclick="checkFacebookLogin();"/>
<div id="fb-root"></div>

当您收到 FB 的回复时,您将获得您注册的应用程序的用户 id。您可以使用此 ID 并获取用户的图像。 下面的代码动态创建一个图像标签并添加到正文中。将此添加到您的 fetchUserDetail() 响应处理程序。

let image = document.createElement("img");
image.src = `https://graph.facebook.com/v2.12/${responseFromFB.id}/picture`;
document.body.appendChild(image);

API 文档 here