[英]Do I need to pass access tokens when using the Javascript SDK?
I'm just getting started with the Graph API and the Javascript SDK. 我刚刚开始使用Graph API和Javascript SDK。 I have a page that will authenticate users using the fb:login-button, and I have successfully posted on status updates using /me/feed. 我有一个页面可以使用fb:login按钮对用户进行身份验证,并且我已经使用/ me / feed成功发布了状态更新。 However, when I try to retrieve a list of Events, or Posts the response is an empty array. 但是,当我尝试检索事件列表或帖子时,响应为空数组。 I've cut and pasted some of the examples from FB docs, and they result in undefined objects. 我剪切并粘贴了FB文档中的一些示例,这些示例导致了未定义的对象。
Am I missing something on authentication? 我在身份验证方面缺少什么吗? My users are authorizing user_events and friend_events. 我的用户正在授权user_events和friend_events。 I figured if I could post, I should be able to read. 我认为如果可以发表,我应该可以阅读。 Hoping it is something obvious. 希望这很明显。
Here is code sample that always results in the error case: 这是总是导致错误情况的代码示例:
function getFriends() {
FB.api('/me/friends', function(response) {
if(response.data) {
$.each(response.data,function(index,friend) {
alert(friend.name + ' has id:' + friend.id);
});
} else {
alert("Error!");
}
});
and my login-button and init code: 以及我的登录按钮和初始化代码:
<fb:login-button autologoutlink="true" perms="status_update,publish_stream,user_events,friends_events"></fb:login-button>
<script language="javascript" type="text/javascript">
FB.init({
appId: 'myappid',
status: true,
cookie: true,
xfbml: true
});
Thanks in advance. 提前致谢。
不,您不必传递access_token ....也许只是一个复制粘贴错字,但是您错过了代码中的右括号
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.