亚马逊电商数据自动化管理接口平台JAVA SP-API接口开发(上)
重要说明
- 本文章为亚马逊系列其中的一篇,具体详见 主页 中亚马逊分类
- 该系列项目均为【CSDN轻夏】原创,未经允许禁止转载
- 如有疑问请添加qq群聊302493982学习咨询
文章目录
开发接口需要导入很多包,一部分是直接导入就行,还有一部分是官方只提供源代码,需要自行下载和编译,将编译好的jar包导入到主工程中。
1、导入常用xml依赖
<dependencies>
<!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-signer -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-signer</artifactId>
<version>1.11.610</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>2.7.5</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-sts</artifactId>
<version>1.11.236</version>
</dependency>
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>stax2-api</artifactId>
<version>4.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
<version>10.7.4</version>
</dependency>
<!--web 依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--lombok 依赖-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!--mysql 依赖-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!--mybatis-plus 依赖-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.1.tmp</version>
</dependency>
<!-- swagger2 依赖 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<!-- Swagger第三方ui依赖 -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>1.9.6</version>
</dependency>
<!--security 依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!--JWT 依赖-->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.0</version>
</dependency>
<!-- google kaptcha依赖 -->
<dependency>
<groupId>com.github.axet</groupId>
<artifactId>kaptcha</artifactId>
<version>0.0.9</version>
</dependency>
<!-- commons-pool2 对象池依赖 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<!--easy poi依赖-->
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-spring-boot-starter</artifactId>
<version>4.1.3</version>
</dependency>
<!--rabbitmq 依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
<!--websocket 依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>io.gsonfire</groupId>
<artifactId>gson-fire</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>org.threeten</groupId>
<artifactId>threetenbp</artifactId>
<version>1.3.5</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>logging-interceptor</artifactId>
<version>2.7.5</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.51</version>
<scope>test</scope>
</dependency>
<!--FastDFS依赖-->
<dependency>
<groupId>org.csource</groupId>
<artifactId>fastdfs-client-java</artifactId>
<version>1.29-SNAPSHOT</version>
</dependency>
</dependencies>
2、导入亚马逊的xml依赖
然后这些依赖仍然不够
需要其他包,不过这些包官方只提供源代码,需要自行下载和编译,将编译好的jar包导入到主工程中。
2-1、先看这个
再此之前需要先打包其他的,详细见 https://zhuanlan.zhihu.com/p/361902178
补充一下该文章
2-2、生成java项目
models中包含许多模块,分别处理不同的功能,用到哪一模块就打包哪一模块,下文管这个叫插件(吐槽:好麻烦,醉了)
这一步中路径要改为自己的路径,下面给出我执行的例子:
生成sellers
java -jar E:\work\IDEA\amazon-api\swagger-codegen-cli-2.4.13.jar generate -i E:\work\IDEA\amazon-api\sellers\sellers.json -l java -t E:\work\IDEA\amazon-api\selling-partner-api-models-main\clients\sellingpartner-api-aa-java\resources\swagger-codegen\templates\ -o E:\work\IDEA\amazon-api\sellers
生成reports
java -jar E:\work\IDEA\amazon-api\swagger-codegen-cli-2.4.13.jar generate -i E:\work\IDEA\amazon-api\reports\reports_2021-06-30.json -l java -t E:\work\IDEA\amazon-api\selling-partner-api-models-main\clients\sellingpartner-api-aa-java\resources\swagger-codegen\templates\ -o E:\work\IDEA\amazon-api\reports
生成messaging
java -jar E:\work\IDEA\amazon-api\swagger-codegen-cli-2.4.13.jar generate -i E:\work\IDEA\amazon-api\messaging\messaging.json -l java -t E:\work\IDEA\amazon-api\selling-partner-api-models-main\clients\sellingpartner-api-aa-java\resources\swagger-codegen\templates\ -o E:\work\IDEA\amazon-api\messaging
生成ordersV0
java -jar E:\work\IDEA\amazon-api\swagger-codegen-cli-2.4.13.jar generate -i E:\work\IDEA\amazon-api\ordersV0\ordersV0.json -l java -t E:\work\IDEA\amazon-api\selling-partner-api-models-main\clients\sellingpartner-api-aa-java\resources\swagger-codegen\templates\ -o E:\work\IDEA\amazon-api\ordersV0
生成financesV0
java -jar E:\work\IDEA\amazon-api\swagger-codegen-cli-2.4.13.jar generate -i E:\work\IDEA\amazon-api\financesV0\financesV0.json -l java -t E:\work\IDEA\amazon-api\selling-partner-api-models-main\clients\sellingpartner-api-aa-java\resources\swagger-codegen\templates\ -o E:\work\IDEA\amazon-api\financesV0
生成catalogItemsV0
java -jar E:\work\IDEA\amazon-api\swagger-codegen-cli-2.4.13.jar generate -i E:\work\IDEA\amazon-api\catalogItemsV0\catalogItemsV0.json -l java -t E:\work\IDEA\amazon-api\selling-partner-api-models-main\clients\sellingpartner-api-aa-java\resources\swagger-codegen\templates\ -o E:\work\IDEA\amazon-api\catalogItemsV0
生成feeds_2021-06-30
java -jar E:\work\IDEA\amazon-api\swagger-codegen-cli-2.4.13.jar generate -i E:\work\IDEA\amazon-api\feeds_2021-06-30\feeds_2021-06-30.json -l java -t E:\work\IDEA\amazon-api\selling-partner-api-models-main\clients\sellingpartner-api-aa-java\resources\swagger-codegen\templates\ -o E:\work\IDEA\amazon-api\feeds_2021-06-30
2-3、打包插件
执行完成之后会获得一个java的maven项目
使用idea打开,引入maven,注意前期打包直接用maven install,不要使用ide的包导入功能,否则在其他项目中仍然需要导入,会造成不必要的错误
2-4、修改pom文件
<dependency>
<groupId>com.amazon.sellingpartnerapi</groupId>
<artifactId>sellingpartnerapi-aa-java</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.amazon.sellingpartnerapi</groupId>
<artifactId>sellingpartner-api-documents-helper-java</artifactId>
<version>1.0.0</version>
</dependency>
在该项目中加入上述依赖项,前提是之前这个项目已经install了
注意在打包该插件时,修改该插件的 artifactId 和 name,例如在打包feeds时,修改为如下
<artifactId>swagger-java-client-feeds</artifactId>
<name>swagger-java-client-feeds</name>
这样就避免了不同模块直接名字相同造成的问题了(吐槽:为什么要起一样的名字,疯子)
2-5、在主项目中引用
然后在主项目中就可以引用了,例子如下:
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-java-client-reports</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-java-client-sellers</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-java-client-sales</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-java-client-messaging</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-java-client-ordersV0</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-java-client-financesV0</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-java-client-catalogItemsV0</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-java-client-feeds</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-java-client-listingsItems</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-java-client-definitionsProductTypes</artifactId>
<version>1.0.0</version>
</dependency>
<!-- 打包其他模块的依赖 sellingpartnerapi-aa-java-->
<dependency>
<groupId>com.amazon.sellingpartnerapi</groupId>
<artifactId>sellingpartnerapi-aa-java</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.amazon.sellingpartnerapi</groupId>
<artifactId>sellingpartner-api-documents-helper-java</artifactId>
<version>1.0.0</version>
</dependency>
3、申请亚马逊权限
先吐槽一波
- 官方文档写的稀烂
- 官方文档都是错的,不要相信,为什么错,不知道,自己琢磨
- 上传数据,既不是uplode,也不是feeds,而是Listings,没有十年脑血栓想不出来
- sp-api和之前那个wms不一样,不兼容
- 可以参考之前wms的文档,因为新出来的文档还不如10年前的旧文档写的明白,不过不能用,不一样,http://docs.developer.amazonservices.com/zh_CN/dev_guide/DG_IfNew.html
- 其实上面一大堆插件,有用的就只有两个,一个是reports或者orders查看订单数据,一个是listings-items上传订单
3-1、申请一大堆乱七八糟东西
首先要申请一大堆东西,看着这个文章就行
https://segmentfault.com/a/1190000040005829?utm_source=sf-similar-article
3-2、获得一大堆乱七八糟东西
应用程序id
amzn1.sp.solution.阿巴阿巴-阿巴阿巴-阿巴阿巴-阿巴阿巴
用户arn
arn:aws:iam::4阿巴阿巴0:user/e阿巴阿巴i
授权应用程序令牌
Atzr|Iw阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴HaQ 澳洲
Atzr|Iw阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴bo 日本
Atzr|Iw阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴1c 欧洲
Atzr|Iw阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴5nw 北美
LWA客户端编码
amzn1.application-oa2-client.1阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴6
LWA客户端秘钥
6阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴16
在控制台切换角色链接
https://signin.aws.amazon.com/switchrole?roleName=role&account=4阿巴阿巴阿巴阿巴0
角色arn
arn:aws:iam::4阿巴阿巴阿巴阿巴0:role/role
用户名
e阿巴阿巴阿巴阿巴i
密码
空
Secret access key
O阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿R
Access key ID
A阿巴阿巴阿巴阿巴U
卖家标志 sellerId
A阿巴阿巴阿巴阿巴N
开发者id
4阿巴阿巴阿巴阿巴0
4、常量
//北美
//加拿大
public static final String CANADA_MARKETPLACE_ID = "A2EUQ1WTGCTBG2";
//美国
public static final String US_MARKETPLACE_ID = "ATVPDKIKX0DER";
//墨西哥
public static final String Mexico_MARKETPLACE_ID = "A1AM78C64UM0Y8";
//巴西
public static final String Brazil_MARKETPLACE_ID = "A2Q3Y263D00KWC";
//欧洲
//西班牙
public static final String Spain_MARKETPLACE_ID = "A1RKKUPIHCS9HS";
//英国
public static final String England_MARKETPLACE_ID = "A1F83G8C2ARO7P";
//法国
public static final String France_MARKETPLACE_ID = "A13V1IB3VIYZZH";
//荷兰
public static final String Netherlands_MARKETPLACE_ID = "A1805IZSGTT6HS";
//德国
public static final String Germany_MARKETPLACE_ID = "A1PA6795UKMFR9";
//意大利
public static final String Italy_MARKETPLACE_ID = "APJ6JRA9NG5V4";
//土耳其
public static final String turkey_MARKETPLACE_ID = "A33AVAJ2PDY3EV";
//阿拉伯联合酋长国
public static final String Arab_MARKETPLACE_ID = "A2VIGQ35RCS4UG";
//印度
public static final String India_MARKETPLACE_ID = "A21TJRUUN4KGV";
//远东
//新加坡
public static final String Singapore_MARKETPLACE_ID = "A19VAU5U5O7RUS";
//澳大利亚
public static final String Australian_MARKETPLACE_ID = "A39IBJ37TRP1C6";
//日本
public static final String Japanese_MARKETPLACE_ID = "A1VC38T7YXB528";
//北美(加拿大、美国、墨西哥和巴西商城)
public static final String US_EAST_1 = "us-east-1";
//欧洲(西班牙、英国、法国、德国、意大利、土耳其、阿联酋和印度商城)
public static final String US_WEST_1 = "eu-west-1";
//远东(新加坡、澳大利亚和日本商城)
public static final String US_WEST_2 = "us-west-2";
//请求地区 北美(加拿大、美国、墨西哥和巴西商城)
public static final String REQUEST_US_EAST_1 = "https://sellingpartnerapi-na.amazon.com";
//请求地区 欧洲(西班牙、英国、法国、德国、意大利、土耳其、阿联酋和印度商城)
public static final String REQUEST_US_WEST_1 = "https://sellingpartnerapi-eu.amazon.com";
//请求地区 远东(新加坡、澳大利亚和日本商城)
public static final String REQUEST_US_WEST_2 = "https://sellingpartnerapi-fe.amazon.com";
//LWA验证服务器URI
public static final String LWA_URL = "https://api.amazon.com/auth/o2/token";
权限常量
//ACCESS_KEY_ID
public static final String ACCESS_KEY_ID = "A阿巴阿巴阿巴阿巴阿巴阿巴U";
//SECRET_KEY
public static final String SECRET_KEY = "O阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴R";
//角色名字
public static final String ROLE_NAME = "e阿巴阿巴阿巴i";
//角色Arn
public static final String ROLE_ARN = "arn:aws:iam::阿巴阿巴阿巴阿巴阿巴阿巴:role/role";
//LWA客户端编码
public static final String LAW_CLIENT = "amzn1.application-oa2-client.阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴";
//LWA客户端秘钥
public static final String LWA_SECRET = "6阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴6";
//北美店铺token
public static final String NORTH_TOKEN = "Atzr|Iw阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴nw";
//欧洲店铺token
public static final String EUROPE_NAME = "Atzr|Iw阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴1c";
//日本店铺token
public static final String JAPANESE_NAME = "Atzr|Iw阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴bo";
//澳洲店铺token
public static final String AUSTRALIA_NAME = "Atzr|Iw阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴阿巴aQ";
5、请求头
public ArrayList<Object> pack_US() {
AWSAuthenticationCredentials awsAuthenticationCredentials = AWSAuthenticationCredentials.builder()
.accessKeyId(ACCESS_KEY_ID)
.secretKey(SECRET_KEY)
.region(US_EAST_1)//请求地区
.build();
AWSAuthenticationCredentialsProvider awsAuthenticationCredentialsProvider = AWSAuthenticationCredentialsProvider.builder()
.roleArn(ROLE_ARN)//IAM角色
.roleSessionName(ROLE_NAME)
.build();
LWAAuthorizationCredentials lwaAuthorizationCredentials = LWAAuthorizationCredentials.builder()
.clientId(LAW_CLIENT)
.clientSecret(LWA_SECRET)
.refreshToken(NORTH_TOKEN)
.endpoint(LWA_URL)//LWA验证服务器URI
.build();
ArrayList<Object> list = new ArrayList<>();
list.add(awsAuthenticationCredentials);
list.add(awsAuthenticationCredentialsProvider);
list.add(lwaAuthorizationCredentials);
return list;
}
ArrayList<Object> pack = pack_US();
XXXXXApi reportsApi = new XXXXXApi.Builder().awsAuthenticationCredentials((AWSAuthenticationCredentials) pack.get(0))
.awsAuthenticationCredentialsProvider((AWSAuthenticationCredentialsProvider) pack.get(1))
.lwaAuthorizationCredentials((LWAAuthorizationCredentials) pack.get(2))
.endpoint(REQUEST_US_EAST_1)//请求地区
.build();
XXXXXApi是插件中的api包下的名字
参考文献
https://gitee.com/penghaiping/amazon-sp-api/tree/master/docs/catalogitems
http://events.jianshu.io/p/59affdb25d53
https://github.com/penghaiping/amazon-sp-api/tree/master/docs
https://segmentfault.com/a/1190000040005829?utm_source=sf-similar-article
https://blog.csdn.net/Sanzhutech/article/details/118637423
https://blog.csdn.net/penghaiping1001/article/details/113524366
https://www.spapi.org.cn/cn/model2/_4_appstore.html
http://blog.sina.com.cn/s/blog_7cb308650102w2lm.html
https://developer-docs.amazon.com/sp-api/docs/the-selling-partner-api-sandbox
https://mp.weixin.qq.com/s/fse3FTBNWfY2nDVbpmeG9w
https://www.amazon.com/gp/help/customer/display.html?nodeId=GGGMZK378RQPATDJ
https://www.51tracking.com/api-index?language=Java#%E5%88%9B%E5%BB%BA%E5%A4%9A%E4%B8%AA%E6%9F%A5%E8%AF%A2