收藏页面     下单流程
分站加盟

api对接下单教程详情

demo链接:https://pan.baidu.com/s/15dJxcYUkGHU7mp69m-HJdg 密码:ubux   这是对接api demo 文件,可以下载使用,里面文件已经包含有 测试的账号和密码了,可以随意测试不收费。 

1 API调用方法详解

开放平台(POP)的API是基于HTTP协议来调用的,开发者(ISV)可以直接使用POP的协议来封装HTTP请求进行调用,以下主要是针对自行封装HTTP请求进行API调用的原理进行详细解说。

调用流程

根据POP的协议:填充参数 > 生成签名 > 拼装HTTP请求 > 发起HTTP请求> 得到HTTP响应 > 解释json结果,以下是大体的调用过程示意图:

空包网API流程

调用入口

调用API的服务URL地址,开放平台目前只提供个环境给ISV使用:正式环境

正式环境: ISV软件应用上线之后使用的环境,此环境的入口与正式测试环境一致,只不过应用上线之后,流量限制会进行打开,具体流量限制与应用所属类目有关,内测阶段详见API文档说明。

正式环境调用拼多多API地址:http://www.kongbao90.com/OrderSubmit/index.asp

注意,只能使用POST请求进行API调用。

公共参数

调用任何一个API都必须传入的参数,目前支持的公共参数有:

  • 参数名称

    参数类型

    是否必填

    参数描述

  • appKey

    String

    网站的用户名,比如 “123456”

  • logiType

    String

    接口的类型如:buykongbao,delbuykongbao,getuseramount,getprice,getadminiamount

  • orders

    String

    订单的详情

  • timestamp

    String

    当前时间,例如:2018-05-25 14:08:05

  • sign

    String

    API输入参数签名结果,签名算法参照下面的介绍。

业务参数

API调用除了必须包含公共参数外,如果API本身有业务级的参数也必须传入,每个API的业务级参数请考API文档说明。

2 签名算法

为了防止API调用过程中被黑客恶意篡改,调用任何一个API都需要携带签名,POP服务端会根据请求参数,对签名进行验证,签名不合法的请求将会被拒绝。

POP目前支持的签名算法为:MD5(sign_method=md5),签名大体过程如下:

1-所有参数进行按照首字母先后顺序排列

2-把排序后的结果按照参数名+参数值的方式拼接

3-首先先把网站用户名的密码进行16位md5加密后转小写成client_secret

4-拼装好的字符串首尾拼接client_secret进行32位md5加密后转大写

调用示例

① 输入参数为

 array (
            'appKey' => '123456',
            'orders' => '{"Platform":"龙邦","SendContact":"发件人","SendOfficePhone":"15888888888","SendCellPhone":"15888888888","SendState":"广东省","SendCity":"广州市","SendDistrict":"番禺区","SendAddress":"岭南大道321号","ProductTitle":"衣服","Weight":"2","Raddress":[{"OrderNo":"T100001111","Contact":"收货人1","OfficePhone":"15888888888","CellPhone":"15888888888","State":"广东省","City":"广州市","District":"番禺区","Address":"岭南大道321号"},{"OrderNo":"T100002","Contact":"收货人2","OfficePhone":"15888888888","CellPhone":"15888888888","State":"广东省","City":"广州市","District":"番禺区","Address":" 岭南大道321号"}]}',
            'logiType' =>'buykongbao',
            'timestamp'=> '2018-05-25 14:08:05',
        )

 

② 按首字母升序排列

 array (
            'appKey' => '123456',
            'logiType' =>'buykongbao',
            'orders' => '{"Platform":"龙邦","SendContact":"发件人","SendOfficePhone":"15888888888","SendCellPhone":"15888888888","SendState":"广东省","SendCity":"广州市","SendDistrict":"番禺区","SendAddress":"岭南大道321号","ProductTitle":"衣服","Weight":"2","Raddress":[{"OrderNo":"T100001111","Contact":"收货人1","OfficePhone":"15888888888","CellPhone":"15888888888","State":"广东省","City":"广州市","District":"番禺区","Address":"岭南大道321号"},{"OrderNo":"T100002","Contact":"收货人2","OfficePhone":"15888888888","CellPhone":"15888888888","State":"广东省","City":"广州市","District":"番禺区","Address":" 岭南大道321号"}]}',
            'timestamp'=> '2018-05-25 14:08:05',
        )

 

连接字符串,并在首尾加上client_secret,假设client_secret为28e5589105438f95,如下:

28e5589105438f95appKey123456logiTypebuykongbaoorders{"Platform":"龙邦","SendContact":"发件人","SendOfficePhone":"15888888888","SendCellPhone":"15888888888","SendState":"广东省","SendCity":"广州市","SendDistrict":"番禺区","SendAddress":"岭南大道321号","ProductTitle":"衣服","Weight":"2","Raddress":[{"OrderNo":"T100001111","Contact":"收货人1","OfficePhone":"15888888888","CellPhone":"15888888888","State":"广东省","City":"广州市","District":"番禺区","Address":"岭南大道321号"},{"OrderNo":"T100002","Contact":"收货人2","OfficePhone":"15888888888","CellPhone":"15888888888","State":"广东省","City":"广州市","District":"番禺区","Address":" 岭南大道321号"}]}timestamp2018-05-25 14:08:0528e5589105438f95

 

③ 生成签名 sign

MD5(28e5589105438f95appKey123456logiTypebuykongbaoorders{"Platform":"龙邦","SendContact":"发件人","SendOfficePhone":"15888888888","SendCellPhone":"15888888888","SendState":"广东省","SendCity":"广州市","SendDistrict":"番禺区","SendAddress":"岭南大道321号","ProductTitle":"衣服","Weight":"2","Raddress":[{"OrderNo":"T100001111","Contact":"收货人1","OfficePhone":"15888888888","CellPhone":"15888888888","State":"广东省","City":"广州市","District":"番禺区","Address":"岭南大道321号"},{"OrderNo":"T100002","Contact":"收货人2","OfficePhone":"15888888888","CellPhone":"15888888888","State":"广东省","City":"广州市","District":"番禺区","Address":" 岭南大道321号"}]}timestamp2018-05-25 14:08:0528e5589105438f95 ) = E4DE3ED21002510DED352819E7AE6775

 

④ 拼装API请求

{ { host } }/OrderSubmit/index.asp?appKey=123456&logiType=buykongbao&orders={"Platform":"龙邦","SendContact":"发件人","SendOfficePhone":"15888888888","SendCellPhone":"15888888888","SendState":"广东省","SendCity":"广州市","SendDistrict":"番禺区","SendAddress":"岭南大道321号","ProductTitle":"衣服","Weight":"2","Raddress":[{"OrderNo":"T100001111","Contact":"收货人1","OfficePhone":"15888888888","CellPhone":"15888888888","State":"广东省","City":"广州市","District":"番禺区","Address":"岭南大道321号"},{"OrderNo":"T100002","Contact":"收货人2","OfficePhone":"15888888888","CellPhone":"15888888888","State":"广东省","City":"广州市","District":"番禺区","Address":" 岭南大道321号"}]}×tamp=2018-05-25 14:08:05&sign=46A53D4980340A8AA2883F271743B7B4

注意事项:

1) 所有的请求和响应数据编码皆为utf-8格式,url里的所有参数值请做urlencode编码。如果请求的Content-Type是 application/x-www-form-urlencoded,所有参数值也做urlencode编码;如果是multipart/form-data格式,每个表单字段的参数值无需编码,但每个表单字段的charset部分需要指定为utf-8

2) 返回数据格式为JSON

 

 

 

buykongbao(购买空包)

 

 

orders json 说明

 

参数接口

参数类型

是否必填

说明

Platform

String

必填

发货快递名字:申通,龙邦,拼多多申通.....等

SendContact

String

必填

发件人名称字符串长度不能大于30,如 李四

SendOfficePhone

String

发件人电话字符串长度不能大于20

SendCellPhone

String

发件人固话字符串长度不能大于20

SendState

String

必填

发件人所在省字符串长度不能大于20,如 广东省

SendCity

String

必填

发件人所在市字符串长度不能大于20,如 广州市

SendDistrict

String

必填

发件人县/区字符串长度不能大于20,如 番禺区

ProductTitle

String

商品名称不能大于100如 衣服

Weight

String

包裹重量两位小数,单位Kg ,如  2

Raddress

json数组

必填

收件人信息

 

Raddress json数组里面的 json 对象,Raddress json数组有几个收货地址对象,就有多少个订单,一次可以多个订单的

 

 参数接口

参数类型

是否必填

说明

OrderNo

String

如 T100001111,订单号只能包含大小写字母,

Contact

String

必填

收货人名字,如 李四

OfficePhone

String

件人电话字符串长度不能大于20

CellPhone

String

件人固话字符串长度不能大于20

State

String

必填

件人所在省字符串长度不能大于20,如 广东省

City

String

必填

收件人所在市字符串长度不能大于20,如 广州市

District

String

必填

件人县/区字符串长度不能大于20,如 番禺区

 

 

例子:orders等于 {"Platform":"龙邦","SendContact":"发件人","SendOfficePhone":"15888888888","SendCellPhone":"15888888888","SendState":"广东省","SendCity":"广州市","SendDistrict":"番禺区","SendAddress":"岭南大道321号","ProductTitle":"衣服","Weight":"2","Raddress":[{"OrderNo":"T100001111","Contact":"收货人1","OfficePhone":"15888888888","CellPhone":"15888888888","State":"广东省","City":"广州市","District":"番禺区","Address":"岭南大道321号"},{"OrderNo":"T100002","Contact":"收货人2","OfficePhone":"15888888888","CellPhone":"15888888888","State":"广东省","City":"广州市","District":"番禺区","Address":" 岭南大道321号"}]}

这是一次性下2个订单。

 

请求示例

 

"http://www.kongbao90.com/OrderSubmit/index.asp?appKey=123456&logiType=buykongbao&orders={"Platform":"龙邦","SendContact":"发件人","SendOfficePhone":"15888888888","SendCellPhone":"15888888888","SendState":"广东省","SendCity":"广州市","SendDistrict":"番禺区","SendAddress":"岭南大道321号","ProductTitle":"衣服","Weight":"2","Raddress":[{"OrderNo":"T100001111","Contact":"收货人1","OfficePhone":"15888888888","CellPhone":"15888888888","State":"广东省","City":"广州市","District":"番禺区","Address":"岭南大道321号"},{"OrderNo":"T100002","Contact":"收货人2","OfficePhone":"15888888888","CellPhone":"15888888888","State":"广东省","City":"广州市","District":"番禺区","Address":" 岭南大道321号"}]}timestamp=2018-05-25 14:08:05&sign=46A53D4980340A8AA2883F271743B7B4

 

 

响应示例

{"code":"0","msg":"下单成功","Data":[{"OrderNo":"T100001111","WaybillSn":"1847734","Trackingno":"709676947681"},{"OrderNo":"T100002","WaybillSn":"1847735","Trackingno":"709676294616"}]}

 

说明

code等于字符串 0  时,就代表下单成功,如果code 不为 0 时都是错误返回,可以判断 code 是否为 0 要确定下单成功或者不成功。

 

 

 

delbuykongbao(删除订单)

 

 

请求示例

http://www.kongbao90.com/OrderSubmit/index.asp?appKey=123456&logiType=delbuykongbao&orders={"trackingno":"7914324048"}&timestamp=2018-05-25 15:32:11&sign=C28807585387E912F195C8BD7279E491

响应示例

成功

{"code":"0","msg":"删除成功","Data":"7914324048"}  

失败

{"code":"1014","msg":"没有此单号","Data":"7914324048"} 

 

 

getuseramount(获取当前用户金额)

 

请求示例

http://www.kongbao90.com/OrderSubmit/index.asp?appKey=123456&logiType=getuseramount&orders={}&timestamp=2018-05-25 15:36:31&sign=309F786410CAE3A19A4A23BBCB9CEEE6

 

响应示例

成功

{"code":"0","msg":"获取用户金额成功","Data":99999999606.6}

 

 

getprice(获取快递的价格)

 

请求示例

http://www.kongbao90.com/OrderSubmit/index.asp?appKey=123456&logiType=getprice&orders={"Platform":"allkd","Adminikey":"51113"}&timestamp=2018-05-25 15:40:41&sign=4D98742D65733AA609094CC33F87616F

说明

orders={"Platform":"allkd","Adminikey":"51113"}    

 如果Platform为 allkd 则返回所有目前上架的快递的价格,如果Platform 为 申通 则单独返回申通快递的价格。

 Adminikey 可以保持为空字符串,这个值需要站长提供,一般只有站长自己使用API才需要,普通用户保持为空就好,如果此值正确的话,可以获取到快递的成本价,获取到后台的权限。

响应示例

{"code":"0","msg":"获取价格详情成功","Data":[{"title":"龙邦速递(仅限淘宝/天猫/阿里使用)","Platform":"龙邦","typ":1,"price1":1.8,"price2":1.7,"price3":1.6,"status":1},{"title":"百世快递(仅限淘宝/天猫/阿里使用)","Platform":"百世","typ":1,"price1":2.1,"price2":2,"price3":1.9,"status":1},{"title":"快捷快递(仅限淘宝/天猫使用)","Platform":"快捷","typ":1,"price1":2.1,"price2":2,"price3":1.9,"status":1},{"title":"快捷快递(仅限淘宝/天猫使用)","Platform":"快捷","typ":1,"price1":2.1,"price2":2,"price3":1.9,"status":1},{"title":"亚风-全国-配送(淘宝天猫可用)勿填错为亚风","Platform":"亚风","typ":1,"price1":1.4,"price2":1.3,"price3":1.2,"status":1},{"title":"淘宝国通(仅限淘宝/天猫使用)","Platform":"国通","typ":1,"price1":1.3,"price2":1.2,"price3":1.1,"status":1},{"title":"增益速递(支持淘宝,天猫,阿里","Platform":"增益","typ":1,"price1":1.4,"price2":1.3,"price3":1.2,"status":1},{"title":"拼多多增益速递(拼多多专用)","Platform":"拼多多增益","typ":1,"price1":1.1,"price2":1,"price3":0.9,"status":1},{"title":"拼多多全峰快递(拼多多专用)","Platform":"拼多多全峰","typ":1,"price1":1.2,"price2":1.1,"price3":1,"status":1},{"title":"拼多多国通快递(拼多多专用)","Platform":"拼多多国通","typ":1,"price1":1.1,"price2":1,"price3":0.9,"status":1},{"title":"拼多多百世快递(拼多多专用)","Platform":"拼多多百世","typ":1,"price1":1.6,"price2":1.5,"price3":1.4,"status":1},{"title":"拼多多申通快递(拼多多专用)","Platform":"拼多多申通","typ":1,"price1":1.5,"price2":1.4,"price3":1.3,"status":1},{"title":"拼多多快捷快递(拼多多专用)","Platform":"拼多多快捷","typ":1,"price1":1.5,"price2":1.4,"price3":1.3,"status":1},{"title":"拼多多亚风速递(拼多多专用)","Platform":"拼多多亚风","typ":1,"price1":1.2,"price2":1.1,"price3":1,"status":1},{"title":"拼多多龙邦快递(拼多多专用)","Platform":"拼多多龙邦","typ":1,"price1":1.3,"price2":1.2,"price3":1.1,"status":1},{"title":"京东申通快递(京东专用,淘宝天猫不可用)","Platform":"京东申通","typ":1,"price1":1.5,"price2":1.4,"price3":1.3,"status":1},{"title":"京东龙邦速递(京东专用,淘宝天猫不可用)","Platform":"京东龙邦","typ":1,"price1":1.4,"price2":1.3,"price3":1.2,"status":1},{"title":"京东亚风速运(京东专用) ","Platform":"京东亚风","typ":1,"price1":1.2,"price2":1.1,"price3":1,"status":1},{"title":"京东快捷快递(京东专用)","Platform":"京东快捷","typ":1,"price1":1.5,"price2":1.4,"price3":1.3,"status":1},{"title":"京东国通快递《京东、拼多多可用》","Platform":"京东国通","typ":1,"price1":1.2,"price2":1.1,"price3":1,"status":1}]}

 

getadminiamount(获取网站后台余额)

 

请求示例

http://www.kongbao90.com/OrderSubmit/index.asp?appKey=123456&logiType=getadminiamount&orders={"Adminikey":"51113"}&timestamp=2018-05-25 15:51:42&sign=581007624B7A09FE5D83EC9056E6004A

说明

 Adminikey  此值需要正确才能使用这个功能,普通用户 不要考虑此功能

响应示例

{"code":"0","msg":"获取管理后台余额成功","Data":0}