From efeeb436f5445bc7b543778c6b9e2124dede62ae Mon Sep 17 00:00:00 2001 From: Samurais Date: Thu, 12 Mar 2020 16:25:19 +0800 Subject: [PATCH] =?UTF-8?q?Updated=20RestAPI=20=E6=96=87=E6=A1=A3=20(markd?= =?UTF-8?q?own)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RestAPI-文档.md | 55 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/RestAPI-文档.md b/RestAPI-文档.md index d079c9c..fa478cf 100644 --- a/RestAPI-文档.md +++ b/RestAPI-文档.md @@ -1 +1,54 @@ -# 春松客服RestAPI \ No newline at end of file +# 春松客服RestAPI + +春松客服目前具备30余个API接口,包括联系人管理,授权,获得访客会话列表等。使用春松客服API需要安装Postman并导入春松客服API Collection文件。 + + +## 安装Postman +Postman支持各种操作系统,下载安装包: +https://www.postman.com/ + + +## 导入春松客服API文件 + +下载[Chatopera_cc_v1.postman_collection.20200312.zip](https://github.com/chatopera/cosin/files/4323043/Chatopera_cc_v1.postman_collection.20200312.zip) + +将zip文件解压,得到 Chatopera_cc_v1.postman_collection.json + +打开Postman,执行导入 + +![image](https://user-images.githubusercontent.com/3538629/76501380-256fe080-647d-11ea-8644-1b53671d6b25.png) + +## API认证 + +导入collection文件后,从左侧找到 **Chatopera_cc_v1** + +![image](https://user-images.githubusercontent.com/3538629/76501495-53552500-647d-11ea-922e-be442aa7c9a1.png) + +认证接口: + +``` +# 获得Token +POST http://IP:PORT/tokens?username=USERNAME&password=PASSWORD +``` +| key | 描述 | +| --- | --- | +| IP | 春松客服IP | +| PORT | 春松客服端口 | +| USERNAME | 用户名 | +| PASSWORD | 密码 | + +回复结果为一个字符串,即Auth token。 + +## 业务API请求 +在请求其它API时,在header中设置`authorization`为Auth token就可以,如下: + +![image](https://user-images.githubusercontent.com/3538629/76501630-9616fd00-647d-11ea-9f51-73ea33548bcf.png) + +针对每个接口的描述,此处不赘述,直接用Postman测试。 + +## 其它注意事项 + +* 每个token有效期为24小时,认证失败会有相应提醒 +* 登录用户的权限有限制,API访问受此约束 + +