gpt4 book ai didi

javascript - 从收件箱获取消息

转载 作者:行者123 更新时间:2023-12-02 19:52:41 26 4
gpt4 key购买 nike

我有关于 Graph API 的问题。

我使用 Javascript 作为 API 并制作了一个小测试网站,您可以在其中登录、查找新消息并写入新状态。

我的问题是我无法获取消息或线程。

FB.api('/me/inbox',function(response) {  alert(response.id); } ); don't work.

有人有一个在收件箱中获取消息的示例吗?

谢谢

最佳答案

/me/inbox request要求您已授予 read_mailbox 权限。

一旦获得,/me/inbox 请求将返回一个 Thread's 的数组。 ,看起来像这样;

{
"data": [
{
"id": "1126884978255",
"from": {
"name": "Someone's Name",
"id": "34723472"
},
"to": {
"data": [
{
"name": "Someone's Name",
"id": "34723472"
},
{
"name": "Matt Lunn",
"id": "560914724"
}
]
},
"message": "Testing the one-ness.",
"updated_time": "2012-01-31T12:13:00+0000",
"unread": 0,
"unseen": 0,
"comments": {
"data": [
{
"id": "1126884978255_6769",
"from": {
"name": "Someone's Name",
"id": "34723472"
},
"message": "£140!?",
"created_time": "2012-01-31T11:33:15+0000"
},
{
"id": "1126884978255_6771",
"from": {
"name": "Matt Lunn",
"id": "560914724"
},
"message": "^^ month in advance as well",
"created_time": "2012-01-31T11:33:26+0000"
}
]
},
"type": "thread"
}
],
"summary": {
"unseen_count": 0,
"unread_count": 21,
"updated_time": "2012-01-31T13:19:31+0000"
}
}

因此,根据您要查找的 ID,您必须这样做;

for (var i=0;i<response.data.length;i++) {
var thread = response.data[i];

for (var j=0;j<thread.comments.data.length;j++) {
var comment = thread.comments.data[j];

console.log(comment.message);
}
}

希望你能明白......

关于javascript - 从收件箱获取消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9078859/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com