带有 PYTHON-AMAZON-AD-API 包的亚马逊广告 API

问题描述 投票:0回答:1

我尝试使用 PYTHON-AMAZON-AD-API packeg,并且我的凭据是带有刷新令牌、客户端 ID、客户端秘密和配置文件 ID 的字典。看起来一切正常,但是当我尝试这段代码时:

try:

    status = 'enabled'

    result=sponsored_products.Campaigns(credentials=credentials, debug=True).list_campaigns(
        stateFilter=status
    )

    payload = result.payload

    logging.info(payload)

except AdvertisingApiException as error:

    logging.info(error)

我明白了(我从这里删除了敏感详细信息):

2023-09-04 11:46:39,312:WARNING:Call to deprecated function list_campaigns endpoint: /v2/sp/campaigns method: GET
2023-09-04 11:46:41,691:INFO:{'User-Agent': 'python-ad-api-0.4.9', 'Amazon-Advertising-API-ClientId': 'XXXXXXXX', 'Authorization': 'Bearer XXXXXX', 'Amazon-Advertising-API-Scope': 'XXXXXX', 'Content-Type': 'application/json'}
2023-09-04 11:46:41,693:INFO:GET https://advertising-api-test.amazon.com/v2/sp/campaigns?stateFilter=enabled
2023-09-04 11:46:41,693:INFO:{'_content': b'<html><body><b>Http/1.1 Service Unavailable</b></body> </html>', '_content_consumed': True, '_next': None, 'status_code': 503, 'headers': {'Server': 'Server', 'Date': 'Mon, 04 Sep 2023 09:46:41 GMT', 'Content-Length': '62', 'Connection': 'keep-alive', 'x-amz-rid': 'HMG7GXBXW27ZJ9VV1NGP', 'Cache-Control': 'no-cache,no-store', 'Pragma': 'no-cache', 'Vary': 'Content-Type,Accept-Encoding,User-Agent', 'Strict-Transport-Security': 'max-age=47474747; includeSubDomains; preload'}, 'raw': <urllib3.response.HTTPResponse object at 0x00000185E2DD26E0>, 'url': 'https://advertising-api-test.amazon.com/v2/sp/campaigns?stateFilter=enabled', 'encoding': None, 'history': [], 'reason': 'Service Unavailable', 'cookies': <RequestsCookieJar[]>, 'elapsed': datetime.timedelta(seconds=1, microseconds=72272), 'request': <PreparedRequest [GET]>, 'connection': <requests.adapters.HTTPAdapter object at 0x00000185E2D917D0>}
2023-09-04 11:46:41,694:INFO:(503, b'<html><body><b>Http/1.1 Service Unavailable</b></body> </html>', {'Server': 'Server', 'Date': 'Mon, 04 Sep 2023 09:46:41 GMT', 'Content-Length': '62', 'Connection': 'keep-alive', 'x-amz-rid': 'HMG7GXBXW27ZJ9VV1NGP', 'Cache-Control': 'no-cache,no-store', 'Pragma': 'no-cache', 'Vary': 'Content-Type,Accept-Encoding,User-Agent', 'Strict-Transport-Security': 'max-age=47474747; includeSubDomains; preload'})

我不明白为什么我总是得到“status_code”:503 ....

有人可以帮我吗?我该怎么办?

我希望得到我的活动列表

python amazon-advertising-api
1个回答
0
投票

Amazon Ads 广告 API 已于 2024 年 3 月 27 日弃用了赞助商品的版本 2 端点。

所以请使用 CampaignsV3.list_campaigns() 方法来获取营销活动列表。

这是相应的 python 包文档的链接。

https://python-amazon-ad-api.readthedocs.io/en/latest/sp/campaigns_v3.html#ad_api.api.sp.CampaignsV3.CampaignsV3.list_campaigns

© www.soinside.com 2019 - 2024. All rights reserved.