提交 b8505825 编写于 作者: O oyj

创建项目

上级
# 运行环境
node 8+
# 安装依赖
```
npm install
```
# 运行
```
cd kdapi
node index.js
```
# 说明
1.申请快递鸟api的应用key
2.更换BUSINESS_ID
3.根据您的需求,按照快递鸟文档对应的指令设置参数
const axios = require('axios')
const md5Hex = require('md5-hex');
const querystring = require('querystring')
const URL = 'http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx'
const KEY = '06920cf9-2f55-49b1-b209-4afaceed36ee';//APP KEY,请向快递鸟申请
const REQUEST_TYPE = '8001';//请求接口指令(8001查询)
const BUSINESS_ID = 'xxxx' //更换用户id
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
const params = {
ShipperCode:'SF',
LogisticCode:'SF1040595620412',
CustomerName:'5690'
}
const sign = Buffer.from(md5Hex(JSON.stringify(params)+KEY)).toString('base64')
async function main(){
const reqParams = {
RequestType:REQUEST_TYPE,
EBusinessID:BUSINESS_ID,
DataSign:sign,
RequestData:JSON.stringify(params),
DataType:2
}
const res = await axios.post(URL,querystring.stringify(reqParams))
console.log(res.data)
return res
}
main()
{
"name": "kdapi",
"version": "1.0.0",
"description": "kdapi demo",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.21.0",
"md5-hex": "^3.0.1"
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册