Is there a way to filter out moderated comments wi

2019-09-05 05:32发布

问题:

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.