简体   繁体   中英

Facebook get username without requesting authentication

I have tried countless examples from all around.. Is there any real way to get the current users name in a fan page app using the JavaScript sdk without a pop up requesting authentication?

Here is my current JS:

window.fbAsyncInit = function() {
    FB.init({
        appId      : 'ID', // App ID
        channelUrl : 'url/channel.php', // Channel File
        status     : true, // check login status
        cookie     : true, // enable cookies to allow the server to access the session
        frictionlessRequests : true, // enable frictionless requests
        xfbml      : true  // parse XFBML
    });
    // Additional initialization code here

    FB.api('/me', function(response) {
    console.log("Welcome " + response.name);
});
};

// Load the JavaScript SDK Asynchronously
(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));

and then my PHP:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#">
<head>
  <meta charset="utf-8" />
  <title>View Source App</title>
   <script type="text/javascript" src="script/jquery.min.js"></script>
   <script type="text/javascript" src="script/script.js"></script>
</head>
<body>
    <div id="fb-root"></div>
  <div id="content">
  <h2>My First App</h2>
  <p>This is some text to make sure my app is working on Facebook</p>
  </div><!--content -->
</body>
</html>

Any Help Greatly Appreciated.

The short answer is no. You need permission to access any user data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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