0

I am trying to download all the posts and the comments(and replies to comments) for that post in a public facebook page. Here is the code that I am using:

from facepy import GraphAPI
import json

page_id = "Google"
access_token = "access_token"

graph = GraphAPI(access_token)



data = graph.get(page_id + "/feed", page=True, retry=3,    limit=100,fields='message,likes')


i = 0
for p in data:
    print 'Downloading posts', i
    with open('facepydata/content%i.json' % i, 'w') as outfile:
       json.dump(p, outfile, indent = 4)
    i += 1

First of all (1) this code is giving me this exception:
facepy.exceptions.FacebookError: [1] Please reduce the amount of data you're asking for, then retry your request
How should I solve this problem?
Second: (2)How can I get all the likes,comments and replies at the same time of getting the posts (paging is also required in likes,comments and replies to get all of them). page=True not working for these fields.

Thank you!

Roya Feizi
  • 13
  • 4
  • 2
    For (1): the error message couldn't be any clearer in how to solve the problem. – Klaus D. Feb 16 '16 at 04:43
  • But I do not want to reduce the amount of data. I want to get all the posts. I am not even asking for comments and replies in that code yet. – Roya Feizi Feb 16 '16 at 11:53

1 Answers1

1

Facebooks Graph API has rate limiting. I believe @Klaus-D is correct that the error it is clear the request should have a lower limit parameter set, in which you can then page through the results of.

I would try limit=10, and then page through with your loop as you have it.

ratchet
  • 195
  • 4
  • 15