我正在玩FB Graph API收集"反应"直到我达到FB限制为100.(我需要查询的一些帖子有超过1000个反应) 我确实看到字典键" next"在json响应中,它是指向下一个组的链接,该组具有下一个键,依此类推。以下是我到目前为止的简化版本......
post_id_list = ['387990201279405_1155752427836508'] #short list for this example
def make_post_reaction_url_list(postid_list, APP_ID, APP_SECRET):
''' constructs a list of FB urls to gather reactions to posts limit set to 3'''
post_id_list_queries = []
for post_id in postid_list:
post_id_list_queries.append("https://graph.facebook.com/v2.8/"+post_id+"?fields=reactions.limit(3)&access_token="+ APP_ID + "|" + APP_SECRET)
return post_id_list_queries
post_id_reaction_query_list = make_post_reaction_url_list(post_id_list, APP_ID, APP_SECRET)
def return_json_from_fb_query(post_id_rection_query_list):
list_o_json = []
for target in post_id_reaction_query_list:
t = requests.get(target)
t_json = t.json()
list_o_json.append(t_json)
return list_o_json
list_o_json = return_json_from_fb_query(post_id_reaction_query_list)
list_o_json[0]['reactions']['data'] #gives me information for the response
list_o_json[0]['reactions']['paging']['next'] #returns a http link to the next set of reactions.
我可以收集的任何建议然后按照" next"链接,收集信息,然后按照下一个链接等到节点的结尾?