Facebook网站API:登录并显示用户图像和名称。主动访问令牌错误
我的问题是显示一个登录按钮,并且(一旦用户登录)显示他的个人资料图像、姓名和“注销”链接 在facebook api文档(此处)中,我发现了以下示例:Facebook网站API:登录并显示用户图像和名称。主动访问令牌错误,facebook,facebook-graph-api,Facebook,Facebook Graph Api,我的问题是显示一个登录按钮,并且(一旦用户登录)显示他的个人资料图像、姓名和“注销”链接 在facebook api文档(此处)中,我发现了以下示例: <html> <head> <title>My Facebook Login Page</title> </head> <body> <div id="fb-root"></div> <script>
<html>
<head>
<title>My Facebook Login Page</title>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'YOUR_APP_ID', // App ID
channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.api('/me', function(user) {
if (user) {
var image = document.getElementById('image');
image.src = 'http://graph.facebook.com/' + user.id + '/picture';
var name = document.getElementById('name');
name.innerHTML = user.name
}
});
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
<div align="center">
<img id="image"/>
<div id="name"></div>
</div>
</body>
</html>
我应该如何使用此“主动访问令牌”为了完成任何用户数据检索,每个Facebook应用程序必须首先验证用户会话,以确保应用程序具有最终用户检索其数据的权限 参考: 使用Javascript SDK检索他们的访问令牌,您应该能够开始检索他们的用户名和图像
Facebook JS SDK:我可以再问你一个问题吗?我尝试使用客户端身份验证,并将“//WWW.YOUR_DOMAIN.COM/channel.html”替换为“”这是我的主页。对吗?
error: Object
code: 2500
message: "An active access token must be used to query information about the current user."
type: "OAuthException"