龙空技术网

SDK使用手册

雨夜漫谈生活 96

前言:

而今看官们对“win10安卓sdk如何配置”大约比较看重,兄弟们都想要知道一些“win10安卓sdk如何配置”的相关知识。那么小编在网摘上网罗了一些关于“win10安卓sdk如何配置””的相关内容,希望朋友们能喜欢,看官们一起来学习一下吧!

为了提升开发者接入抖店API的效率,我们上线了SDK功能,使用SDK可以轻松完成API的调用、API响应结果的获取,开发者可在控制台下载直接使用。

当前SDK功能支持JAVA、PHP、Python、Golang等语言,其他语言后续更新。

版本依赖

JAVA: JDK 1.7+

如何下载进入 应用后台 -> 开发工具 -> SDK下载构建SDK开发包 点击 点击打包等待打包完毕后,点击 直接下载/源码包下载 获取sdk或者sdk源码包导入到自己的工程中,参考下节如何使用

Golang SDK本地导入方法:

A. 将下载的压缩包解压,得到源码文件夹

B. 将源码文件夹拷贝到自己的项目工程中,路径任意,例如lib文件夹下:

C. 打开自己项目工程的go.mod文件:

在required模块添加「doudian.com/open/sdk_golang v1.0.0」在replace模块添加「doudian.com/open/sdk_golang => ./lib/sdk-golang」

D. 执行go build命令编译,没有报错说明导入sdk包成功

获取Acccess TokenJAVA自用型应用获取Access Token

//设置appKey和appSecret,全局设置一次GlobalConfig.initAppKey("xxxxxxxxxx");GlobalConfig.initAppSecret("xxxxxxxxxx");//入参为shopIdAccessToken accessToken = AccessTokenBuilder.build(123456L) //123456是shopId
工具型应用获取Access Token
//设置appKey和appSecret,全局设置一次GlobalConfig.initAppKey("xxxxxxxxxx");GlobalConfig.initAppSecret("xxxxxxxxxx");//入参为codeAccessToken accessToken= AccessTokenBuilder.build("xxxxxxxxxx")  //16dde1a3-2d6f-4946-aef2-afbd29d2eb92是code
应用自己管理Access Token
//设置appKey和appSecret,全局设置一次GlobalConfig.initAppKey("xxxxxxxxxx");GlobalConfig.initAppSecret("xxxxxxxxxx");//入参是自己获取的accessToken字符串AccessToken accessToken= AccessTokenBuilder.parse("xxxxxxxxxx");
PHP自用型应用获取Access Token
//设置appKey和appSecret,全局设置一次GlobalConfig::getGlobalConfig()->appKey = "xxxxxxxx";GlobalConfig::getGlobalConfig()->appSecret = "xxxxxxxx";$accessToken = AccessTokenBuilder::build(123456, ACCESS_TOKEN_SHOP_ID);
工具型应用获取Access Token
//设置appKey和appSecret,全局设置一次GlobalConfig::getGlobalConfig()->appKey = "xxxxxxxx";GlobalConfig::getGlobalConfig()->appSecret = "xxxxxxxx";$accessToken = AccessTokenBuilder::build("xxxxxxxxxx", ACCESS_TOKEN_CODE);
应用自己管理Access Token
//设置appKey和appSecret,全局设置一次GlobalConfig::getGlobalConfig()->appKey = "xxxxxxxx";GlobalConfig::getGlobalConfig()->appSecret = "xxxxxxxx";$accessToken = AccessTokenBuilder::parse("xxxxxxxxxx");
Golang自用型应用获取Access Token
//设置appKey和appSecret,全局设置一次doudian_sdk.GlobalConfig.AppKey = "xxxxxxxx"doudian_sdk.GlobalConfig.AppSecret = "xxxxxxxxxx"accessToken, err := doudian_sdk.BuildAccessToken(&doudian_sdk.BuildAccessTokenParam{ShopId: 4463798})
工具型应用获取Access Token
//设置appKey和appSecret,全局设置一次doudian_sdk.GlobalConfig.AppKey = "xxxxxxxx"doudian_sdk.GlobalConfig.AppSecret = "xxxxxxxxxx"accessToken, err := doudian_sdk.BuildAccessToken(&doudian_sdk.BuildAccessTokenParam{Code: "xxxxxxxx"})
应用自己管理Access Token
//设置appKey和appSecret,全局设置一次doudian_sdk.GlobalConfig.AppKey = "xxxxxxxx"doudian_sdk.GlobalConfig.AppSecret = "xxxxxxxxxx"accessToken, err := doudian_sdk.ParseAccessToken("xxxxxxxxxx")
Python自用型应用获取Access Token
//设置appKey和appSecret,全局设置一次GlobalConfig.appKey = "xxxxxx"  # appKeyGlobalConfig.appSecret = "xxxxxxxx"  # appSecret# 获取tokentoken = AccessTokenBuilder.buildTokenByShopId("[your shop id]")
工具型应用获取Access Token
GlobalConfig.appKey = "xxxxxx"  # appKeyGlobalConfig.appSecret = "xxxxxxxx"  # appSecret# 获取tokentoken = AccessTokenBuilder.buildTokenByCode("[your code]")
应用自己管理Access Token
GlobalConfig.appKey = "xxxxxx"  # appKeyGlobalConfig.appSecret = "xxxxxxxx"  # appSecret# 获取tokentoken = AccessTokenBuilder.parse("[your access token]")
.NET Core自用型应用获取Access Token
//设置appKey和appSecret,全局设置一次GlobalConfig.GetGlobalConfig().AppKey = "xxxxxx";GlobalConfig.GetGlobalConfig().AppSecret = "xxxxxxxx";//获取tokenvar accessToken = AccessTokenBuilder.Build(123456); //传的是店铺id(数字类型)
工具型应用获取Access Token
//设置appKey和appSecret,全局设置一次GlobalConfig.GetGlobalConfig().AppKey = "xxxxxx";GlobalConfig.GetGlobalConfig().AppSecret = "xxxxxxxx";//获取tokenvar accessToken = AccessTokenBuilder.Build("xxxxxxx"); //传的是code(字符串类型)
应用自己管理Access Token
//设置appKey和appSecret,全局设置一次GlobalConfig.GetGlobalConfig().AppKey = "xxxxxx";GlobalConfig.GetGlobalConfig().AppSecret = "xxxxxxxx";//获取tokenvar accessToken = AccessTokenBuilder.Parse("xxxxxxx"); //传的是自己缓存的access token(字符串类型)
刷新Access TokenJAVA
//设置appKey和appSecret,全局设置一次GlobalConfig.initAppKey("6989147827339429420");GlobalConfig.initAppSecret("284371ec-c15c-489e-9ce1-673b243603c6");accessToken = AccessTokenBuilder.refresh(accessToken)
PHP
//设置appKey和appSecret,全局设置一次GlobalConfig::getGlobalConfig()->appKey = "xxxxxxxx";GlobalConfig::getGlobalConfig()->appSecret = "xxxxxxxx";$accessToken = AccessTokenBuilder::refresh($accessToken);
Golang
//设置appKey和appSecret,全局设置一次doudian_sdk.GlobalConfig.AppKey = "xxxxxxxx"doudian_sdk.GlobalConfig.AppSecret = "xxxxxxxxxx"accessToken, err := doudian_sdk.RefreshAccessTokenParam(&doudian_sdk.RefreshAccessTokenParam{RefreshToken: "xxxxxxxxxx"})
Python
//设置appKey和appSecret,全局设置一次GlobalConfig.appKey = "xxxxxx"  # appKeyGlobalConfig.appSecret = "xxxxxxxx"  # appSecret# 获取tokentoken = AccessTokenBuilder.refreshToken("refresh token") //传创建token返回结果中的refreshToken字符串
.NET Core
//设置appKey和appSecret,全局设置一次GlobalConfig.GetGlobalConfig().AppKey = "xxxxxx";GlobalConfig.GetGlobalConfig().AppSecret = "xxxxxxxx";//获取tokenvar accessToken = AccessTokenBuilder.Refresh(123456); //传创建token返回结果中的refreshToken字符串

注意:只有通过build方法拿到的accessToken才支持调用refresh方法

调用Open Api

以/address/list为例:

JAVA

AddressListRequest request = new AddressListRequest();AddressListParam param = request.getParam();param.setPageNo(1L);param.setPageSize(20L);param.setShopId(123456L);AddressListResponse resp = request.execute(accessToken);System.out.println(response);
PHP
$request = new AddressListRequest();$param = new AddressListParam();$request->setParam($param);$param->page_no = 1;$param->page_size = 10;$param->shop_id = 123456;$request->execute($accessToken);
Golang
request := address_list_request.New()request.GetParams().PageNo = 1request.GetParams().PageSize = 10request.GetParams().ShopId = 123456response := request.Execute(accessToken)
Python
request = AddressListRequest();request.getParams().page_no = 1request.getParams().page_size = 20request.getParams().shop_id = 123456response = request.execute(token)print(response)
.NET Core
AddressListRequest request = new AddressListRequest();AddressListParam param = request.BuildParam();param.PageNo = 1;param.PageSize = 20;param.ShopId = 123456;AddressListResponse resp = request.execute(accessToken);
完整DemoJAVA
//设置appKey和appSecret,全局设置一次GlobalConfig.initAppKey("6989147827339429420");GlobalConfig.initAppSecret("284371ec-c15c-489e-9ce1-673b243603c6");//创建Access TokenAccessToken accessToken = AccessTokenBuilder.build("263e343c-fd86-42c4-b724-36f732cb281c");if(!accessToken.isSuccess()) {    //todo    return;}//构建Open Api请求参数AddressListRequest request = new AddressListRequest();AddressListParam param = request.getParam();param.setPageNo(1L);param.setPageSize(20L);param.setShopId(123456L);//调用Open ApiAddressListResponse response = null;try {    response = request.execute(accessToken);}catch (DoudianOpException e){    //处理异常}
PHP
//设置appKey和appSecret,全局设置一次GlobalConfig::getGlobalConfig()->appKey = "xxxxxxxx";GlobalConfig::getGlobalConfig()->appSecret = "xxxxxxxx";//创建Access Token$accessToken = AccessTokenBuilder::build(1111114035, ACCESS_TOKEN_SHOP_ID);if(!accessToken->isSuccess()) {    //todo    return;}//构建Open Api请求参数$request = new AddressListRequest();$param = new AddressListParam();$request->setParam($param);$param->page_no = 1;$param->page_size = 10;$param->shop_id = 123456;//调用Open Api$request->execute($accessToken);
Golang
//设置appKey和appSecret,全局设置一次doudian_sdk.GlobalConfig.AppKey = "xxxxxxxx"doudian_sdk.GlobalConfig.AppSecret = "xxxxxxxxxx"//创建Access TokenaccessToken, err := doudian_sdk.BuildAccessToken(&doudian_sdk.BuildAccessTokenParam{ShopId: 4463798})if err != nil {    panic(err)}//构建Open Api请求参数request := address_list_request.New()request.GetParams().PageNo = 1request.GetParams().PageSize = 10request.GetParams().ShopId = 123456//调用Open Apiresponse := request.Execute(accessToken)
Python
#设置appKey和appSecret,全局设置一次GlobalConfig.appKey = "xxxxxx"  # appKeyGlobalConfig.appSecret = "xxxxxxxx"  # appSecret#创建Access Tokentoken = AccessTokenBuilder.buildTokenByShopId("[your shop id]")#构建Open Api请求参数request = AddressListRequest();request.getParams().page_no = 1request.getParams().page_size = 20request.getParams().shop_id = 123456#调用Open Apiresponse = request.execute(token)
.NET Core
//设置appKey和appSecret,全局设置一次GlobalConfig.GetGlobalConfig().AppKey = "xxxxxx";GlobalConfig.GetGlobalConfig().AppSecret = "xxxxxxxx";//创建Access Tokenvar accessToken = AccessTokenBuilder.Build(123456); //传的是店铺id(数字类型)//构建Open Api请求参数AddressListRequest request = new AddressListRequest();AddressListParam param = request.BuildParam();param.PageNo = 1;param.PageSize = 20;param.ShopId = 123456;//调用Open ApiAddressListResponse resp = request.execute(accessToken);
有多个AppKey和AppSecret需要管理JAVA
DoudianOpConfig config = new DoudianOpConfig();config.setAppKey("your_app_key");config.setAppSecret("your_app_secret");AccessToken accessToken = AccessTokenBuilder.build(config, DefaultDoudianOpClient.getDefaultClient(), "code");AddressListRequest request = new AddressListRequest();request.setConfig(config);//set param heretry {    response = request.execute(accessToken);}catch (DoudianOpException e){    //处理异常}
PHP

暂不支持

对外文档中不支持接口列表

接口名称

接口类目

/sku/syncStock

商品API

/product/detail

商品API

/sku/list

商品API

/product/addV2

商品API

/sku/editPrice

商品API

/product/getCateProperty

商品API

/product/editV2

商品API

/product/setOnline

商品API

/sku/editCode

商品API

/product/setOffline

商品API

/product/del

商品API

/product/list

商品API

/refund/shopRefund

售后退款API

/afterSale/buyerReturn

售后退款API

/afterSale/firmReceive

售后退款API

/afterSale/refundProcessDetail

售后退款API

/afterSale/buyerRefund

售后退款API

/trade/refundListSearch

售后退款API

/order/settle

账单API

标签: #win10安卓sdk如何配置