I want to get all comments of a facebook post. We can extract comments by passing the limit()
in Api call But how we know the limit? I need all comments.
https://graph.facebook.com/10153608167431961?fields=comments.limit(100).summary(true)&access_token=LMN
By using this
data = graph.get_connections(id='10153608167431961', connection_name='comments')
I am getting few comments. How can I get all comments of a post?
Edit
import codecs
import json
import urllib
import requests
B = "https://graph.facebook.com/"
P ="10153608167431961"
f = "?fields=comments.limit(4).summary(true)&access_token="
T = "EAACb6lXwZDZD"
url = B+P+f+T
def fun(data):
nextLink = (data['comments']['paging']['next'])
print(nextLink)
for i in data['comments']['data']:
print (i['message'])
html = urllib.request.urlopen(nextLink).read()
data = json.loads(html.decode('utf-8'))
fun(data)
html = urllib.request.urlopen(url).read()
d = json.loads(html.decode('utf-8'))
fun(d)
It is giving the error
KeyError: 'comments'