对接亚马逊 ads api( Amazon Advertising API) 第一章:申请授权

目录

1、申请亚马逊开发者账号

1.1、登录/注册,进入页面,并点击右上角的登录

1.2、登录或者注册亚马逊开发者账号

1.3、新建security profile

1.3.1、在菜单栏找到 login with Amazon

1.3.2、create a new security profile

1.3.3、填写相关资料

1.3.4、保存成功后将会回到 login with Amazon 页面

1.3.5、回到亚马逊广告API的首页,填写右侧的相关信息

1.3.6、提交之后会有邮件通知你是否完成注册

2、创建 API 授权并且刷新令牌(Create API authorization and refresh tokens)

2.1、创建 authorization code

2.1.1、根据地区选择url

2.1.2、参数配置

2.1.3、进入2.1.2拼接的url,你就会被要求登录。这里会有两种情况

2.1.4、允许之后将会重定向到一个新的url。将当前的url里面的 code 参数保存下来。

2.2、Call the authorization URL to request authorization and refresh tokens

2.2.1、选择和2.1.1相同区域的url。

2.2.2、参数配置

2.2.3、请求header

2.2.4、请求token

2.2.5、返回栗子

2.2.6、刷新token

如有不对的地方,欢迎指出。共勉~!

问题集锦

Java 对接亚马逊广告API接口(Amazon AWS API) 第二章:沙盒测试


亚马逊广告官网Amazon Advertising Advanced Tools Center

1、申请亚马逊开发者账号

官网教程: Amazon Advertising Advanced Tools Center

登录Amazon的常见问题(FAQ): Login with Amazon frequently asked questions (FAQ).

1.1、登录/注册,进入页面,并点击右上角的登录

亚马逊开发人员服务

1.2、登录或者注册亚马逊开发者账号

如果是注册账号。创建了一个新帐户之后,您将被重定向到开发人员注册页面。

1.3、新建security profile

1.3.1、在菜单栏找到 login with Amazon

1.3.2、create a new security profile

1.3.3、填写相关资料

1.3.4、保存成功后将会回到 login with Amazon 页面

这个页面将会显示security profile name 和 OAuth2 credentials 

OAuth2 credentials 包含 client ID  client secret。将这两个信息保存起来。后面生成 token 的时候会用到。

1.3.5、回到亚马逊广告API的首页,填写右侧的相关信息

API | 亚马逊广告

====================== 注意要点 ====================================

1、在请描述计划的解决方案和功能(Comments)中可以指定

Data Provider
DSP需求方平台
Sponsored Display展示推广
Sponsored Brands品牌推广
Sponsored Products商品推广

If you are a direct advertiser, please submit your account type (ie. Seller, Vendor) and your merchant token or entity ID

如果您是直接广告主,请提交您的账户类型(即卖家、供应商)和您的卖家令牌或实体 ID

可以直接提供上述的相关信息,就不用管表单中的参数了。

2、What do you plan to manage with the API?

因为需要下载 Sponsored Products 的费用报告,所以这个地方要选择 Advertising API

==============================================================

1.3.6、提交之后会有邮件通知你是否完成注册

我们需要回答相关的问题完成注册。

1.3.6.1、第一封邮件。

Thanks for your interest in the Advertising API.

The API allows you to programmatically manage Sponsored Ads campaigns, ad groups, ads, keywords, bids, and budgets. In addition, detailed reporting allows you to pull performance data to analyze sales and investments.

To proceed with your request please reply to the following questions.

· How did you find out about the Amazon Advertising API

· Are you using Sponsored Ads already?

· Are you a seller or a vendor or a third party managing sellers or vendors?

· What solution are you trying to build/what process are you trying to automate?

· What is the target audience for your solution (e.g. are you planning to build an in-house solution to manage your Amazon Advertising campaigns? Do you plan to make the solution available to others?)

Best regards,
The Advertising API-Team

1.3.6.2、第二封邮件。

Thank you for providing more details about your request.

Could you please elaborate or provide us a detailed description of the solution you are trying to build?

This would help us to provide the best possible support.

Best Regards,

The Advertising API-Team

1.3.6.3、第三封邮件

大致是要求公司名、公司官网和邮箱必须使用相同的域名。

Hi,

Thanks for your interest in the Advertising API.

During registration, you provided a company name (XXXXXXXXXXX) that does not match your email domain (XXXX@outlook.com) or/ and website domain (www.amazon.com/shops/XXXXXXXX). We require consistent details (Company name, Email and Website URL) in order to proceed with your request.

Can you please provide us consistent details? For example, if your company name is “ABC”, then website has to be “ABC.com” then email has to be xyz@ABC.com

This information will help us to provide best possible support.

Best Regards,

The Advertising API-Team

==================== 2021-02-20 补充 ==========================

关于这个域名的问题。我是用中国公司去申请的,所以来回了多次这个问题的邮件。最终通过美国商标网证明了我公司是我公司

==============================================================

1.3.6.4、第四封邮件

会让我们选择即将使用的类型

Thanks for your interest in the Amazon Advertising API.​

Can you please specify which solution you are trying to build using our Advertising API?

Best Regards,
The Advertising API Team​​​

1.3.6.5、第五封邮件

这一步似乎和Amazon Advertising Advanced Tools Center是一样的(即帐号使用的区域有哪些)。我们将NA, EU, and FE 这三个都回复过去即可。

Thanks for your interest in the Advertising API.

Which advertisers, in which regions, are requesting that you integrate with Amazon Advertising API for data providers? Are these existing Amazon DSP advertisers?

This information helps to provide the best possible support.

Best Regards,
The Advertising API Team​​​

1.3.6.6、第六封邮件

至此我们就已经通过了邮件的考验!

We are excited to invite you to use the Amazon Advertising API! 

To get started, please do the following:

1.Make sure your developers or your technical team have read the Getting Started Guide and are aware of the API reference, which they will require to develop your integration.
 
2.As a first step, you will need to sign in to an existing Amazon Developer account or you can register a new account if you haven’t already done so. Please make sure to use this account for accessing the Amazon Advertising API.
Ø  To do this make sure to select “Sign In” in the top right hand corner of the website. There you can sign in with your existing account or create a new one.

3.Before you can register your application, you need to agree to the Amazon Advertising Data Provider agreement and to the Amazon Advertising API License Agreement found here. 
 

4.Once you have accepted the license agreement, select the application you wish to use to access the Amazon Advertising API.
 
A support account will be created for the email address used for this API invitation. Please reply to this email with the name and email address for any additional contacts who need an API support account. Registered accounts will receive direct alerts for issues impacting the API service and notification of product releases and features.

Please use your JIRA support account if you have any further questions/concerns with any of the above steps.

As a last step, we kindly ask you to fill out our feedback survey here to improve upon the API onboarding experience.

 点击第三步链接后会出现下面的页面,至此帐号授权完成。

Bug

 当你复制链接的时候,会发现链接长这样,OCID是空的。

https://advertising-api.amazon.com/apim/logIn?state={{OCID}}&locale=en_US

 

解决方法(Nowbe 提供)

将 OCID 替换成【卖家店铺ID】。

如果还不行,回邮件给亚马逊,说这个链接不行。他们会给你一个新的~

2、创建 API 授权并且刷新令牌(Create API authorization and refresh tokens)

官方教程: Amazon Advertising Advanced Tools Center

授权基于OAuth 2.0的规则

AudienceDescription
AdvertiserSeller Central or Amazon Advertising Console user that can create and manage advertising campaigns.
Advertising API DeveloperThe owner of a Login with Amazon account that makes calls to the Amazon Advertising API directly, typically on behalf of an advertiser. An API developer typically requires permission - granted using Login with Amazon - from an advertiser to create and manage campaigns.

2.1、创建 authorization code

2.1.1、根据地区选择url

RegionURL prefix
North America (NA)https://www.amazon.com/ap/oa
Europe (EU)https://eu.account.amazon.com/ap/oa
Far East (FE)https://apac.account.amazon.com/ap/oa

2.1.2、参数配置

ParameterDescription
client_idThe Client ID value that you retrieved in the prerequisites section of this document.
scopeThe OAuth 2.0 permission scope used to limit the application's access to an advertiser's account.
For the Sponsored Brands, Sponsored Display, and Sponsored Products APIs, set scope to cpc_advertising:campaign_management.
For the Data Provider API, set scope to advertising::audiences.
For the DSP API, set scope to advertising::campaign_management.
response_typeThe type of response. Always set to code.
redirect_uriThe value from the Allowed Return URLs field, retrieved in the prerequisites section of this document.

e.g.以北美举例。

https://www.amazon.com/ap/oa?client_id= YOUR_LWA_CLIENT_ID&scope= advertising::campaign_management&response_type=code&redirect_uri= YOUR_RETURN_URL

============================ 注意要点 ===========================

这个链接相当于帐号授权了。我们需要到亚马逊后台去请求这个链接。一旦同意即完成亚马逊帐号对开发者帐号的授权。

注意:不要用你的 develop account 去登录通过授权,而是用 amazon account 去授权。

==================================================================

2.1.3、进入2.1.2拼接的url,你就会被要求登录。这里会有两种情况

非Data Provider API使用你在 Login with Amazon 中注册的帐号
Data Provider API使用你在additional setup steps for the Data Provider API中按不同区域申请的帐号。并且使用和当期url 相同区域的帐号登录

登录之后,直接点击允许(Allow)即可。

==================== 2020-08-12 添加 ==========================

拼接完成后请求出现这个bug。这是我们还没有通过亚马逊API申请。

============================================================

==================== 2021-02-20 添加 ==========================

通过邮件之后,再次测试。然而还是报错了... 但是这个bug还是很好处理的,只需要在对应位置添加上对应的回调URL就可以了。

在 Login With Amazon 里找到 web 设置,填上你的redirect_uri即可。可以填写亚马逊官网

============================================================

2.1.4、允许之后将会重定向到一个新的url。将当前的url里面的 code 参数保存下来。

Amazon.com

2.2、Call the authorization URL to request authorization and refresh tokens

2.2.1、选择和2.1.1相同区域的url。

RegionAuthorization URL
North America (NA)https://api.amazon.com/auth/o2/token
Europe (EU)https://api.amazon.co.uk/auth/o2/token
Far East (FE)https://api.amazon.co.jp/auth/o2/token

2.2.2、参数配置

ParameterDescription
grant_typeMust be authorization_code.
codeThe authorization code retrieved in 2.1.4.
redirect_uriOne of the values from the consent privacy notice URL field. Recall that you retrieved this value in the prerequisites section of this document.
client_idThe Client ID value that you retrieved in the prerequisites section of this document.
client_secretThe Client Secret value that you retrieved in the prerequisites section of this document.

2.2.3、请求header

  • Content-Type:application/x-www-form-urlencoded
  • charset=UTF-8

2.2.4、请求token

curl  \
    -X POST \
    -H "Content-Type:application/x-www-form-urlencoded;charset=UTF-8" \
    --data "grant_type=authorization_code&code=AUTH_CODE&redirect_uri=YOUR_RETURN_URL&client_id=YOUR_CLIENT_ID&client_secret=YOUR_SECRET_KEY" \
    https://api.amazon.com/auth/o2/token

2.2.5、返回栗子

{
    "access_token": "",
    "refresh_token": "",
    "token_type": "bearer",
    "expires_in": 3600
}
FieldDescription
access_tokenThe authorization token.
refresh_tokenThe refresh token.
token_typeThe type of OAuth 2.0 token. Always set to bearer.
expires_inThe length of time until the authorization token expires, in seconds. token过期时间(秒)

Postman 测试

2.2.6、刷新token

curl \                                                                                                                                                        
    -X POST \
    -H "Content-Type:application/x-www-form-urlencoded;charset=UTF-8" \
    --data "grant_type=refresh_token&client_id=YOUR_CLIENT_ID&refresh_token=YOUR_REFRESH_TOKEN&client_secret=YOUR_CLIENT_SECRET" \
    https://api.amazon.com/auth/o2/token

Postman 测试

那么至此申请授权方面就已经完成了。接下来我会写第二章测试具体的API。

如有不对的地方,欢迎指出。共勉~!

问题集锦

问题答案
亚马逊 MWS和AWS 开发者帐号是否通用不通用,需要分别申请。
多个亚马逊卖家店铺是否需要申请多个开发者帐号只需要申请一个,其他的通过授权即可。不同区域可通过不同的api区分区域。

Java 对接亚马逊广告API接口(Amazon AWS API) 第二章:沙盒测试

  • 9
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 33
    评论
### 回答1: 可以使用以下代码进行淘宝 API对接,以读取指定商品的价格信息:import requestsurl = 'https://api.taobao.com/{version}/{namespace}/{method}'headers = { 'Authorization': 'Bearer {token}', 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' }data = { 'item_id': '123456' }response = requests.post(url, headers=headers, data=data)price_info = response.json()['data']['price'] ### 回答2: 要对接淘宝的API并读取商品的价格信息,以下是一段简单的示例代码。 首先,你需要安装Python的HTTP请求库requests和淘宝SDK。 ```python import requests from taobao import * # 设置淘宝开放平台的appkey和appsecret appkey = 'your_appkey' appsecret = 'your_appsecret' # 设置请求的URL和参数 url = 'https://eco.taobao.com/router/rest' params = { 'method': 'taobao.item.get', 'app_key': appkey, 'format': 'json', 'v': '2.0', 'fields': 'price', 'num_iids': '12345678' } # 发送请求并获取响应 response = requests.get(url, params=params) result_json = response.json() # 解析响应数据 if 'item' in result_json: item = result_json['item'] price = item['price'] print('商品价格为:', price) else: print('获取商品信息失败') ``` 以上代码将使用requests库发送HTTP GET请求到淘宝API的`taobao.item.get`接口,通过`num_iids`参数传入商品的ID,获取该商品的价格信息。请记得将`your_appkey`和`your_appsecret`替换为你在淘宝开放平台申请的App Key和App Secret。 需要注意的是,以上代码仅为简单示例,实际开发中可能还需要处理认证、错误处理、结果的保存等其他逻辑。本示例只是一个起点,具体的对接过程和实现会根据你所选择的具体的淘宝API和业务需求而有所不同。 ### 回答3: 要对接淘宝的API,并读取商品的价格信息,可以按照以下步骤进行: 1. 首先,注册成为淘宝开放平台的开发者,并创建一个应用,获取到App Key和App Secret,这是后续进行API调用的凭证。 2. 选择合适的API接口,淘宝提供了多种API接口,可以根据需求选择获取商品价格信息的接口,例如"淘宝客商品详情查询"接口。 3. 在代码中引入相关的API调用库,例如可以使用Python的requests库发送HTTP请求。 4. 在代码中设置请求参数,包括App Key、App Secret、API接口名以及其他必要的参数,例如要查询的商品ID。 5. 构建请求URL,将参数拼接到URL中。 6. 使用HTTP请求方法发送请求,并获取服务器返回的响应。 7. 解析服务器返回的响应,获取商品的价格信息。 8. 对返回的价格信息进行处理和展示,可以将价格信息输出到控制台,或者保存到文件中。 需要注意的是,对接淘宝的API需要遵循淘宝开放平台的相关规范和安全机制,例如签名验证等。在代码开发过程中,可以参考淘宝开放平台的文档和示例代码,以确保API调用的正确性和安全性。 总之,根据以上步骤,编写代码可以实现对接淘宝的API,并读取商品的价格信息。具体实现过程可能因编程语言而异,可以根据具体情况进行调整和修改。
评论 33
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值