I’ve run into some snags in downloading reports through Facebook API.
From documentation https://developers.facebook.com/docs/payments/developer_reports_api/
#Example company access_token request
#Sample developer request for a daily detail report:
wget "https://paymentreports.facebook.com/234599349987627/report?
date=2012-05-15&
type=detail&
access_token=234599349987627|aBc_dEFaEUZbqpatkrp8pbtwXyZ"
#The request above would return a file named 234599349987627_detail_2012-05-15.csv.zip.
However, when in a python script I am writing, using urllib2 to fetch the file described:
url = "https://paymentreports.facebook.com/%s/report?date=%s&type=%s&access_token=%s" % (COMPANY_ID, DATE, reporttype, ACCESS_TOKEN)
reportszipped = ZipFile(StringIO(urllib2.urlopen(url).read()))
I get an HTTP Error:
{"error":{"message":"Access denied.: Access denied due to invalid credentials."}}
I know that my company_id and access_token are correct, having followed the instructions described in the documentation to generate it (without errors). wget the same URL returns the same HTTP Error.
Am I missing something here?
Have you enabled an app for payments, since facebook states on the developer page that:
Check out this page here.