我能得到它的工作使用下列捲曲
curl --cert ./<PI2 CERTIFICATE FILE>.p12 --pass <PI2 CERTIFICATE PASSWORD> -H "Authorization: orgId=45230" -H "Content-Type: application/json" -X POST -d ' {"startTime": "2017-04-06", "endTime": "2017-04-06", "granularity": 2, "selector": {"orderBy":[{"field":"localSpend","sortOrder":"DESCENDING"}], "fields": ["localSpend"], "pagination": { "offset": 0, "limit": 1000 } }, "groupBy": ["COUNTRY_CODE"], "returnRowTotals": false, "returnRecordsWithNoMetrics": false }' "https://api.searchads.apple.com/api/v1/reports/campaigns/campaign name/searchterms"
您可以通過以下如果您使用的是Python的請求,使這裏提到 https://developer.apple.com/library/content/documentation/General/Conceptual/AppStoreSearchAdsAPIReference/API_Overview.html#//apple_ref/doc/uid/TP40017495-CH7-SW8
步驟獲得P12證書因爲我沒有找到任何將p12證書和密碼作爲輸入的參數,所以在發送後可能需要做一些額外的工作。創建一個CRT文件和PEM使用OpenSSL的
openssl pkcs12 -in Apple_Certificate.p12 -out file.crt.pem -clcerts -nokeys
openssl pkcs12 -in Apple_Certificate.p12 -out file.key.pem -nocerts -nodes
,並使用下面的代碼
headers = {
'Authorization': 'orgId=<ORG_ID>',
'Content-Type': 'application/json',
}
data = ' {"startTime": "%s",
"endTime": "%s",
"granularity": 2, ' \
'"selector": {"orderBy":[{"field":"localSpend","sortOrder":"DESCENDING"}], ' \
'"fields": ["localSpend"], "pagination": { "offset": 0, "limit": 1000 } }, ' \
'"groupBy": ["COUNTRY_CODE"], "returnRowTotals": false, "returnRecordsWithNoMetrics": false }' % (date_report, date_report)
url = 'https://api.searchads.apple.com/api/v1/reports/campaigns/%s/searchterms' % (your_campaign_id)
r = requests.post(url, headers=headers, data=data,
cert=('<path to crt file>',
'<path to key file>'))
謝謝你的分享,保存一些好的小時 – AdrianBR