I am having a problem parsing the JSON results from a facebook graph api query (2.5) in python.
I'm trying to get the comments on a status message.
Here's the direct url: where "specific_post_id" is the id of a status post of a page. where "access_token" is the app_id and secret_key from facebook.
The graph explorer is useful as well to see the actual JSON https://developers.facebook.com/tools/explorer/
def getFacebookPageCommentData(post_id, access_token, num_comments):
# construct the URL string
base = "https://graph.facebook.com"
node = "/" + post_id + "/comments/"
parameters = "?fields=id,message,created_time,like_count,parent&limit=%s&access_token=%s" % (num_comments, access_token) # changed
url = base + node + parameters
# retrieve data
data = json.loads(request_until_succeed(url))
return data
test_comment = getFacebookPageCommentData(post_id, access_token, 1)["data"][0]
print test_comment
[{u'created_time': u'2016-02-23T22:37:34+0000',u'id': u'XXXXXXXXXXXXX_XXXXXXXXXXX',u'like_count': 2,u'message': u'"Your" ? Government'}]
I expected to get some nested JSON back with a "from" field that contains additional data. However, I don't get that back. I'm sure there is some small error, but I can't seem to find it.
["data"][0], the from data isn't in the rest of the .JSON is it? - JCollerton