Is there a way to filter out moderated comments with the graph API?

末鹿安然 提交于 2019-12-12 02:28:42

问题


We use comment moderation, and the graph API is returning everything (including comments that should be hidden). There doesn't appear to be a way to see the status of the comments or filter them out of the results.


回答1:


You can use FQL to query only comments that are public. Use the is_private column of comment table to do it (as Ryan says). Let me add some examples:

For example to see 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

Note that you can also make multiple queries to get more info about the user, for example:

# 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



回答2:


I was able to filter out moderated comments by querying the comment table with FQL. The comment table has an is_private field that you can use to filter out the moderated comments.



来源:https://stackoverflow.com/questions/9475075/is-there-a-way-to-filter-out-moderated-comments-with-the-graph-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!