手把手教你从零开始搭建Amazon Advertising-API开发环境(二)之获取SP广告数据

1. 获取access_token

官方链接

1.1 请求路径 POST
地区 URL
NA https://api.amazon.com/auth/o2/token
EU https://api.amazon.co.uk/auth/o2/token
FE https://api.amazon.co.jp/auth/o2/token
1.2 请求事例
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
1.3 代码实操
 //获取access_token的方法,以NA地区为例。
HashMap<String, Object> map = new HashMap<>();
map.put("grant_type","refresh_token");            map.put("refresh_token","your refresh_token");
map.put("client_id","your client_id");
map.put("client_secret","your client_secret");
String getAccessUrl = "https://api.amazon.com/auth/o2/token";
String result = HttpUtil.doPost(getAccessUrl,map,null);
Map map1 = JSONObject.parseObject(result, Map.class);
String access_token = (String) map1.get("access_token");
System.out.println("access_token = " + access_token);

运行结果如下:

在这里插入图片描述

2. 获取profileId

官方连接

2.1 请求路径 GET
https://advertising-api.amazon.com/v2/profiles
2.2 请求参数
参数名称 可能的值(string)
apiProgram billing, campaign, paymentMethod, store, report, account, posts
accessLevel edit, view
profileTypeFilter seller, vendor, agency
validPaymentMethodFilter true, false

请求头:

key value
Content-Type application/json
Authorization access_token
Amazon-Advertising-API-ClientId your client_id
2.3 代码实操
String url = "https://advertising-api.amazon.com/v2/profiles?apiProgram=billing&profileTypeFilter=seller&validPaymentMethodFilter=true";
HashMap<String, String> headerMap = new HashMap<>();
headerMap.put("Content-Type"
  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值