相关疑难解决方法(0)

Facebook javascript sdk必须使用活动访问令牌来查询有关当前用户的信息

在我的代码中我有

FB.api('/me/friends', function(response) {
            if(response.data) {
                //TODO : what to do if no. of friends is more than 5000 (pagination by fb)
                friends_data=response.data;
                dijit.registry.byId("mainWidget_div").set_friends_data(friends_data);
            } else {
                alert("Error!");
            }

          });
Run Code Online (Sandbox Code Playgroud)

这给出了一个错误.但是,如果我手动调用此函数(在控制台上),则没有错误

FB.api('/me/friends', function(response){r=response;});
//wait a while
r
Run Code Online (Sandbox Code Playgroud)

现在r.data是我的一群朋友.

我检查了网络面板,我收集到,当我手动调用它时,访问令牌会自动插入到请求URL中,当通过代码调用它时,访问令牌不会被插入.

我的应用程序中的完整fb sdk加载代码是这样的:

<script type="text/javascript">
      // You probably don't want to use globals, but this is just example code
      var fbAppId = "{{facebook_app_id}}";

      // This is boilerplate code that is used to initialize the Facebook
      // JS SDK. …
Run Code Online (Sandbox Code Playgroud)

facebook facebook-graph-api facebook-javascript-sdk facebook-access-token

7
推荐指数
1
解决办法
1万
查看次数