对接eBay流程(demo可直接运行)

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<String> getAuthUrl() {
    OAuth2Api oauth2Api = new OAuth2Api();
    List<String> 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<OAuthResponse> 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<Response> 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

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

手把手教你如何正确使用ebay-demo(奶爸级别教程)
手把手教你如何正确使用ebay-demo(奶爸级别教程)
手把手教你如何正确使用ebay-demo(奶爸级别教程)

评论 15
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

雨润泽林

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值