我有一个user object,但它的唯一属性是education, first_name, id, last_name, link, locale, location, name, timezone, updated_time, verified
。不仅缺少应该公开的属性(如picture
),而且这些值与文档(updated_time
vs last_updated
)不同。最后,奇怪的是,我从文档页面上的链接(here)获得了同样的结果。最终,我试图获得user.feed
。Facebook API - 返回奇怪值的用户对象
任何想法正在发生什么将不胜感激。我错过了明显的东西吗?
来访https://graph.facebook.com/me/feed给出以下:
{ “错误”:{ “类型”: “OAuthException”, “消息”:“一种主动访问令牌必须被用来查询 信息关于当前用户。“
}}
为什么我需要一个有效的访问令牌? the docs说picture
和feed
是公开的!
这是代码。该user
对象被记录到Firebug.console:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<script src="http://connect.facebook.net/en_US/all.js" type="text/javascript"></script>
<script type="text/javascript">
function update_user_box() {
var user_box = document.getElementById("user");
FB.api('/me', function(user) {
user_box.innerHTML = "<fb:profile-pic uid=\"loggedinuser\" useyou=\"false\"></fb:profile-pic>"
+ "Hey " + user.first_name + "<br>";
FB.XFBML.parse();
console.log(user);
});
}
</script>
</head>
<body>
<div id='user'><fb:login-button onlogin="update_user_box();"></fb:login-button></div>
<br><br>
<div id="fb-root"></div>
<script>
FB.init({
appId : 'b07e858317c9069d450023b7500b4511',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.getLoginStatus(function(response) {
if (response.session) {
update_user_box();
} else {
// no user session available, someone you dont know
}
});
</script>
</body>
</html>
尝试用用户名或ID`https://graph.facebook.com/{ID @用户名} /饲料/`得到 – haha 2010-12-22 22:09:37
你每次你想要API提供数据作为JSON对象时都需要access_token。我认为你对公共饲料是正确的。你可以尝试像这样手动https://graph.facebook.com/me/feed?access_token={YOUR_ACCESS_TOKEN} – Nishant 2010-12-22 22:16:39
@haha是的工作。 https://graph.facebook。COM/ID_OR_USER_NAME /饲料 – Nishant 2010-12-22 22:19:29