有没有办法用图API过滤掉评论的评论?

时间:2012-02-28 01:26:02

标签: facebook-graph-api comments

我们使用评论审核,图API会返回所有内容(包括应隐藏的评论)。似乎没有办法查看评论的状态或将其从结果中过滤掉。

2 个答案:

答案 0 :(得分:2)

您可以使用FQL仅查询公开的评论。使用注释表的is_private列来完成它(正如Ryan所说)。让我举几个例子:

例如,要查看only public comments

SELECT post_fbid, fromid, object_id, text, time \
FROM comment \
WHERE object_id IN \
  (SELECT comments_fbid \
   FROM link_stat \
   WHERE url ='http://developers.facebook.com/docs/reference/fql/comment/') \
  AND is_private = 0

请注意,您还可以进行多次查询以获取有关该用户的更多信息,例如:

# select comments from url
query1 = "SELECT post_fbid,fromid, object_id, text, time, comments "\
        "FROM comment WHERE object_id IN " \
        "(SELECT comments_fbid FROM link_stat WHERE url ='%s')" \
        " and is_private = 0" % (url)

# select all users from query1 and get their names and ids
query2 = "SELECT uid, name FROM user " \
         "WHERE uid IN (SELECT fromid FROM #query1)"

# let use string and not json.dumps cos ordering is important
query = '{"query1": "%s", "query2": "%s"}' % (query1, query2)

# make query to facebook using fql  and the query...
final_query = "https://graph.facebook.com/fql?q=%s" % query

答案 1 :(得分:0)

我可以通过comment查询FQL表来过滤掉评论的评论。注释表有一个is_private字段,您可以使用该字段筛选出已审核的注释。