我已经尝试了无数的例子。有没有什么真正的方法可以在没有弹出请求身份验证的情况下使用 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>
非常感谢任何帮助。