简体   繁体   English

使用Javascript SDK时需要传递访问令牌吗?

[英]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.

相关问题 使用Javascript SDK的Facebook长期访问令牌 - Facebook long term access tokens using the Javascript sdk 在Facebook Javascript SDK中使用“应用程序访问令牌”吗? - Use “app access tokens” with the Facebook Javascript SDK? 使用谷歌自动完成时是否需要实现会话令牌 - Do you need to implement session tokens when using google autocomplete 为什么需要使用JavaScript SDK对凭证进行硬编码才能连接到AWS? - Why do I need to hardcode credentials to connect to AWS using the javascript SDK? 使用?时需要使用“ =”吗? :javascript快捷方式? - Do I need to use an “=” when using the ? : javascript shortcut? 当我需要一个文件夹但似乎不可能时,如何使用require安装SDK? - how do I install an SDK using require, when I need to require an folder and this seems impossible? 在OAuth2中使用Access Tokens with JavaScript - Using Access Tokens with JavaScript in OAuth2 如何确定使用JavaScript SDK时twilio呼叫实际上已被应答? - How do I find out when a twilio call has actually been answered when using the JavaScript SDK? Ruby On Rails-使用require.js时,我需要一个JavaScript文件来通过ruby - Ruby On Rails - I need a javascript file to pass though ruby when using require.js 我什么时候需要指定JavaScript协议? - When do I need to specify the JavaScript protocol?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM