对接eBay流程(demo可直接运行)
发布日期:2021-05-07 04:49:56 浏览次数:28 分类:精选文章

本文共 2398 字,大约阅读时间需要 7 分钟。

eBay对接流程

我看到有很多人有疑问,我留下我的联系方式,方便回答你们的问题:

有问题可以联系企鹅:805460597
有问题可以联系企鹅:805460597
有问题可以联系企鹅:805460597

文末有demo使用教程!!!

文末有demo使用教程!!!
文末有demo使用教程!!!

首先,你必须要有个eBay的开发者账号,然后使用开发者账号的信息去跳转到eBay的授权页面,拿到授权code,之后,你就可以随意控制卖家的所有操作了。

下面详细的说下操作流程:

第一步:

在这里插入图片描述

第二步:

点击上图的”User Tokens“,

在这里插入图片描述

第三步:

点击上图中的Get a Token from eBay via Your Application,然后填写上你的https的回调地址;如图

在这里插入图片描述

第四步:

以上准备设置完之后,就开始进入对接阶段了。

首先,你得弄明白这张图:

在这里插入图片描述

这个图表达的意思是:先从应用端请求eBay授权服务,跳转到eBay授权页面,由卖家登录后得到授权码(Authorization code),再使用这个授权码去请求eBay的接口获取token,最后,用这个token去调用eBay的api接口;

具体流程参考官网文档:https://developer.ebay.com/api-docs/static/oauth-authorization-code-grant.html

第一步:获取eBay授权页面的地址

@GetMapping("getAuthUrl")public Mono
getAuthUrl() { OAuth2Api oauth2Api = new OAuth2Api(); List
scopeList = new ArrayList<>(); scopeList.add("https://api.ebay.com/oauth/api_scope"); scopeList.add("https://api.ebay.com/oauth/api_scope/sell.fulfillment"); scopeList.add("https://api.ebay.com/oauth/api_scope/sell.fulfillment.readonly"); String authorization_url = oauth2Api.generateUserAuthorizationUrl(EBayEnvironment.PRODUCTION, scopeList, Optional.empty()); return Mono.just(authorization_url);}

第二步:根据授权url地址响应的code,去eBay获取token

@GetMapping("getToken/{code}")public Mono
getToken(@PathVariable("code") final String code) throws IOException { OAuth2Api oauth2Api = new OAuth2Api(); OAuthResponse oauth2Response = oauth2Api.exchangeCodeForAccessToken(EBayEnvironment.PRODUCTION, code); return Mono.just(oauth2Response);}

第三步:根据token获取订单数据

@GetMapping("getOrders/{token}")public Mono
getOrders(@PathVariable("token") final String token) throws IOException { final OkHttpClient okHttpClient = new OkHttpClient(); final Request request = new Request.Builder() .url("https://api.ebay.com/sell/fulfillment/v1/order") .get() .addHeader("Authorization", "Bearer " + token) .build(); final Response response = okHttpClient.newCall(request).execute(); return Mono.just(response);}

**

重要的事要多说几遍:

**

demo地址:https://github.com/GoldWater16/eBay-demo
demo地址:https://github.com/GoldWater16/eBay-demo
demo地址:https://github.com/GoldWater16/eBay-demo
demo地址:https://github.com/GoldWater16/eBay-demo
demo地址:https://github.com/GoldWater16/eBay-demo
demo地址:https://github.com/GoldWater16/eBay-demo
demo地址:https://github.com/GoldWater16/eBay-demo

如果实在不知道怎么使用,可以看看下面这个:

上一篇:基于springboot2.x集成缓存注解及设置过期时间
下一篇:如何通过maven执行shell脚本

发表评论

最新留言

初次前来,多多关照!
[***.217.46.12]2025年04月16日 08时08分28秒