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
  }
}
4

1 回答 1

2

我遇到了同样的问题,而且我找到了解决这个问题的唯一方法——使用 FQL 多查询而不是 Graph 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中的名称替换author_id。

如果您需要有关用户或消息的其他信息 - 只需在 SELECT 查询语句中添加列。

希望这可以帮助。

于 2013-03-13T12:13:32.383 回答