首页 文章

没有评论数组的Facebook Graph API收件箱邮件

提问于
浏览
1

Graph API中的一些收件箱消息没有注释数组 . 注释是线程中的实际消息 . API用户是否无法使用这些消息?

例:

{
    "unread": 0,
    "to": {
        "data": [
            {
                "id": "666397291",
                "name": "Miguel Paraz"
            },
            {
                "id": "xxxxxx",
                "name": "xxxxxx"
            }
        ]
    },
    "id": "56002435955",
    "updated_time": "2013-01-19T06:33:59+0000",
    "unseen": 0
}

当我在Facebook网站或移动应用程序中打开收件箱时,评论就在那里 .

当我试图专门检索这个线程时,我得到:

{
  "error": {
    "message": "Unsupported get request.",
    "type": "GraphMethodException",
    "code": 100
  }
}

1 回答

  • 2

    我有同样的问题,只有这样,我发现要解决这个问题 - 使用FQL多重查询而不是图谱API . 使用此查询:

    {
        'messages': 'SELECT body,created_time, author_id  FROM message WHERE thread_id IN 
        (SELECT thread_id FROM thread WHERE folder_id = 0) and author_id != me() ORDER BY created_time DESC',
        'names': 'SELECT uid, name FROM user WHERE uid IN (SELECT author_id FROM #messages)' 
        }
    

    重新调整结果,如下所示:

    {
          "data": [
            {
              "name": "messages", 
              "fql_result_set": [
                {
                  "body": "body of message", 
                  "created_time": 1344741084, 
                  "author_id": 0
                },...
              ]
            }, 
            {
              "name": "names", 
              "fql_result_set": [
                {
                  "uid": "id of user from first query", 
                  "name": "user_name"
                },...
              ]
            }
          ]
        }
    

    然后我首先将第二个查询的结果解析为hashmap,然后在第一个查询到我的数据结构的解析结果之后,用hashmap中的name替换author_id .

    如果您需要有关用户或消息的其他信息 - 只需向SELECT语句添加列 .

    希望这可以帮助 .

相关问题