FBJS好友生日oauth 2.0

发布于 2024-12-09 11:37:46 字数 773 浏览 5 评论 0原文

我的 FB.login( 函数以范围结束,因为它应该:

}, {scope:'user_birthday,friends_birthday'});

在用户登录函数 requestsTest() 触发后:

function permissionsTest(){
    FB.api('me/friends?fields=birthday', {fields:'birthday'}, function(response) { 
        alert(response.data[1]);
        });
}

但是所有警报返回的是:[object Object] 当我试图看到类似的东西时:12/09/1983

这应该如何工作?

参见: graph.facebook.com/me/friends?fields=birthday

您可以清楚地看到有一个名为“data”的对象,其中包含一个名为“id”的对象数组, “生日”

我的之前的尝试:
response.data[1] 返回 [object Object]
响应返回 [object Object]
response.data[1].id 返回未定义
response.data[1].birthday 返回未定义
response.id 返回未定义
response.birthday 返回未定义

我似乎无法正确理解,我觉得我已经用尽了文档、堆栈和谷歌。

my FB.login(function ends with scope as it should:

}, {scope:'user_birthday,friends_birthday'});

after the user logs in the function permissionsTest() fires:

function permissionsTest(){
    FB.api('me/friends?fields=birthday', {fields:'birthday'}, function(response) { 
        alert(response.data[1]);
        });
}

But all the alert returns is: [object Object] when I am trying to see something like: 12/09/1983

How should this work?

see: graph.facebook.com/me/friends?fields=birthday

You can clearly see that there is an object called "data" holding an array of objects called "id" and "birthday"

My previous attempts:
response.data[1] returns [object Object]
response returns [object Object]
response.data[1].id returns undefined
response.data[1].birthday returns undefined
response.id returns undefined
response.birthday returns undefined

I can't seem to get it right and I feel I have exhausted the docs, stack and google.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红玫瑰 2024-12-16 11:37:46

有些朋友的生日可能为空。使用 Facebook Graph API Explorer 查看响应

{
  "data": [
    {
      "birthday": "03/03", 
      "id": "997"
    }, 
    {
      "id": "998"
    },
    {
      "birthday": "05/06/1986", 
      "id": "999"
    }
]

这是为我返回数据:

FB.api('me/friends?fields=birthday', {fields:'birthday'}, function(response) { 
  for (var i = 0; i < response.data.length; i++) {
    alert(response.data[i].birthday);
  }
});

Some of the friends birthdays may be null. Check out the response with the Facebook Graph API Explorer:

{
  "data": [
    {
      "birthday": "03/03", 
      "id": "997"
    }, 
    {
      "id": "998"
    },
    {
      "birthday": "05/06/1986", 
      "id": "999"
    }
]

This was returning data for me:

FB.api('me/friends?fields=birthday', {fields:'birthday'}, function(response) { 
  for (var i = 0; i < response.data.length; i++) {
    alert(response.data[i].birthday);
  }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文