2012-12-01 69 views
1

我已經遇到了一些通過Facebook API下載報告的障礙。Facebook付款報告 - 憑據問題

從技術文檔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. 

然而,當在Python腳本我寫信,用的urllib2獲取描述文件:

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())) 

我得到一個HTTP錯誤: {"error":{"message":"Access denied.: Access denied due to invalid credentials."}}

我知道我的company_idaccess_token是正確的,跟着我在文檔中描述的產生它的錯誤(沒有錯誤)。 wget相同的URL會返回相同的HTTP錯誤。

我在這裏錯過了什麼嗎?

回答

0

是否啓用付款的應用程序,因爲Facebook的開發者頁面上指出:

Before you can proceed, you'll need to make sure that you've enabled an app for payments, including setting up a company to receive payments. Once you've done that, you'll find your company ID and secret on your Company Settings page.

查看此頁面here

+0

感謝您的鏈接和建議。我沒有管理實際的應用程序(只是處理付款統計信息);但仔細檢查它是否已啓用。 Facebook上的文檔有點含糊 - 這裏的問題可能是請求需要使用oauth進行簽名嗎? – zvxr

+0

我的錯誤原來是因爲我使用的是爲我的應用程序生成的access_token,而不是爲公司生成的。 – zvxr