Facebook获取用户名而不请求身份验证

时间:2013-06-06 20:01:20

标签: javascript authentication authorization facebook-javascript-sdk

我尝试了无数的例子..有没有真正的方法可以使用JavaScript sdk在粉丝专页应用中获取当前用户名,而不需要弹出请求身份验证?

这是我目前的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));

然后我的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>

任何帮助都非常赞赏。

1 个答案:

答案 0 :(得分:3)

简短的回答是否定的。您需要获得访问任何用户数据的权限。