日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > windows >内容正文

windows

java系统对接方案_阿里巴巴开放平台SDK(java版). 接入授权店铺数据,对接企业内部管理系统的解决方案...

發(fā)布時(shí)間:2024/3/24 windows 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java系统对接方案_阿里巴巴开放平台SDK(java版). 接入授权店铺数据,对接企业内部管理系统的解决方案... 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

AlibabaSDK-java

阿里巴巴開放平臺SDK. 接入授權(quán)店鋪數(shù)據(jù),對接企業(yè)內(nèi)部管理系統(tǒng)的解決方案

獲取授權(quán)鏈接

@Test

public void testGetPreAuthUrl() throws Exception {

PreAuthAPIPlot plot = new PreAuthAPIPlot("******", "1688",

"http://www.eastmall.vip/ali-pre-auth", "******");

String url = plot.getAuthorizationUrl();

System.out.println(url);

}

用授權(quán)碼換取令牌

@Test

public void testAccessTokenExecutor() throws Exception {

String clientId = "******";

String clientSecret = "******";

String redirectUrl = "http://www.eastmall.vip/ali-pre-auth";

String preAuthCode = "2c823974-63c8-4e5c-b3d5-09a6bacd5057";

AccessTokenExecutor executor = new AccessTokenExecutor(clientId, clientSecret, redirectUrl, preAuthCode);

ResponseEntity result = executor.invoke();

System.out.println(result);

}

刷新令牌

@Test

public void testRefreshTokenExecutor() throws Exception {

String clientId = "******";

String clientSecret = "******";

String refreshToken = "41227eb4-520e-48e0-a432-7d17c870bf6c";

RefreshTokenExecutor executor = new RefreshTokenExecutor(clientId, clientSecret, refreshToken);

ResponseEntity result = executor.invoke();

System.out.println(result);

}

更新令牌,通常如果refresh_token到期前一個(gè)月才允許更新令牌

@Test

public void testRenewRefreshTokenExecutor() throws Exception {

String clientId = "******";

String clientSecret = "*******";

String accessToken = "8f4b8fd6-d71b-4a25-8cc3-2ea3a4333f46";

String refreshToken = "41227eb4-520e-48e0-a432-7d17c870bf6c";

RenewRefreshTokenExecutor executor = new RenewRefreshTokenExecutor(clientId, clientSecret, accessToken,

refreshToken);

ResponseEntity result = executor.invoke();

System.out.println(result);

}

取得訂單列表(賣家視圖)

@Test public void testOrderListOnSellerViewExecutor() throws Exception {

AuthorizationToken token = new AuthorizationToken();

token.setAccess_token("8f4b8fd6-d71b-4a25-8cc3-2ea3a4333f46");

token.setAliId(123456789l);

token.setMemberId("******");

token.setClientId("******");

token.setClientSecret("******");

token.setExpires_in(35999);

token.setRefresh_token("41227eb4-520e-48e0-a432-7d17c870bf6c");

token.setRefresh_token_timeout("20181113172954000+0800");

token.setResource_owner("zheming");

ParamsOfOrderListOnSellerView param = new ParamsOfOrderListOnSellerView();

param.setPage(1);

param.setPageSize(20);

// 如果失敗,是否再試一次

boolean retryIfFail = true;

OrderListOnSellerViewExecutor executor = new OrderListOnSellerViewExecutor(token, param, retryIfFail);

ResponseEntity result = executor.invoke();

System.out.println(result);

}

取得訂單詳情(賣家視圖)

@Test

public void testOrderOnSellerViewExecutor() throws Exception {

AuthorizationToken token = new AuthorizationToken();

token.setAccess_token("8f4b8fd6-d71b-4a25-8cc3-2ea3a4333f46");

token.setAliId(1234546789l);

token.setMemberId("*******");

token.setClientId("******");

token.setClientSecret("******");

token.setExpires_in(35999);

token.setRefresh_token("41227eb4-520e-48e0-a432-7d17c870bf6c");

token.setRefresh_token_timeout("20181113172954000+0800");

token.setResource_owner("zheming");

ParamsOfOrderDetailOnSellerView param = new ParamsOfOrderDetailOnSellerView();

param.setOrderId("159310337253103128");

// 如果失敗,是否再試一次

boolean retryIfFail = true;

OrderDetailOnSellerViewExecutor executor = new OrderDetailOnSellerViewExecutor(token, param, retryIfFail);

ResponseEntity result = executor.invoke();

System.out.println(result);

}

令牌刷新后續(xù)處理句柄

/*

* 句柄 模擬器

*

*/

public class HandlerSimulator {

/*

*

*/

public void notifyOfHandlerPurpose(Object object) {

System.out.println("notifyOfHandlerPurpose:" + object.toString());

}

}

演示令牌刷新后續(xù)處理句柄

@Test

public void testOrderOnSellerViewExecutorWithTokenRefreshHandler() throws Exception {

/*

* 本測試使用內(nèi)部類,實(shí)際工作時(shí)調(diào)用外部類的方法

*/

HandlerSimulator handlerSimulator = new HandlerSimulator();

AuthorizationToken token = new AuthorizationToken();

token.setAccess_token("****");

token.setAliId(123456789l);

token.setMemberId("b2b-123456");

token.setClientId("******");

token.setClientSecret("******");

token.setExpires_in(35999);

token.setRefresh_token("41227eb4-520e-48e0-a432-7d17c870bf6c");

token.setRefresh_token_timeout("20181113172954000+0800");

token.setResource_owner("zheming");

ParamsOfOrderDetailOnSellerView param = new ParamsOfOrderDetailOnSellerView();

param.setOrderId("159310337253103128");

// 如果失敗,是否再試一次

boolean retryIfFail = true;

OrderDetailOnSellerViewExecutor executor = new OrderDetailOnSellerViewExecutor(token, param, retryIfFail);

/*

* 注入令牌刷新的后續(xù)處理句柄

* 要求,注入的方法必須是處理JSON.toJSON的令牌實(shí)體

*/

executor.attachAfterAccessTokenRefreshHandler(handlerSimulator, "notifyOfHandlerPurpose");

ResponseEntity result = executor.invoke();

System.out.println(result);

}

總結(jié)

以上是生活随笔為你收集整理的java系统对接方案_阿里巴巴开放平台SDK(java版). 接入授权店铺数据,对接企业内部管理系统的解决方案...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。