我对 Facebook 的 fql.multiquery 方法感到困惑。
我正在尝试检索帖子上的所有评论,然后还检索每个评论的用户信息。我可以毫无问题地获得评论,但我无法获得用户。
目前我正在使用以下内容:
FB.api({
method: 'fql.multiquery',
queries: {
query1: 'SELECT post_fbid, fromid, text, time FROM comment WHERE post_id="'+postID +'"',
query2: 'SELECT id, name, url, pic FROM profile WHERE id IN (SELECT fromid FROM #query1)'
}
},
function(response) {
}
})
这给了我以下回应:
[
{
"name": "query1",
"fql_result_set": [
{
"post_fbid": "xxxxx",
"fromid": user1id,
"text": "Here's a comment",
"time": 1308579931
},
{
"post_fbid": "xxxxx",
"fromid": user2id,
"text": "Another comment",
"time": 1308580031
}
]
},
{
"name": "query2",
"fql_result_set": [
{
"id": user1id,
"name": "User 1 name",
"url": "User 1 url",
"pic": "User 1 pic"
},
{
"id": user2id,
"name": "User 2 name",
"url": "User 2 url",
"pic": "User 2 pic"
}
]
}
]
问题是,我不知道如何匹配这些!因此,我正在遍历评论,并希望打印每个评论的文本,并在其旁边显示用户名。我怎么做?
或者,有没有更好的方法来做到这一点?