接口鉴权

所有api接口的调用都必须进行接口鉴权 即在http post 请求中加入一些请求头及请求参数(sig)

注意:七陌会提供两个账户,鉴权信息要用到“用户中心”的账户和密码在对接数据查询中查询,鉴权要用到的信息账户Id即账户编号。

1 请求头

Content-Type:application/json;charset=utf-8;
Authorization: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX;

  • Authorization是包头验证信息 Authorization的值为 Base64编码(账户Id +冒号+时间戳) 其中账户Id可以去对接数据查询里查询。 七陌会提供两个账号,一个是8xxx@xxx,另一个是xxx。对接数据查询用全是字母的账号查询。 例如: N00000000556:20161013113612 base64编码后: TjAwMDAwMDAwNTU2OjIwMTYxMDEzMTEzNjEy

  • 冒号为英文冒号

  • 时间戳是当前系统时间,格式"yyyyMMddHHmmss",需与sig参数中时间戳相同。

2 请求参数(sig)

例如:

http://apis.7moor.com/v20160818/customer/getTemplate/N00000000556
?sig=3E92F146297FCA751F63493877EC9719
  • URL后必须带有sig参数,例如sig=AAABBBCCCDDDEEEFFFGGG。

  • sig的值为 32位大写MD5加密 (帐号Id + 帐号APISecret +时间戳)

例如 N00000000556secret20161013113612

md5加密后为 88996D9907E0EE52C5DAF8EFFCC31CFC

  • 时间戳是当前系统时间,格式"yyyyMMddHHmmss"。时间戳是24小时制,如:20140416142030,有效期为5分钟,即生成生成sig后必须在五分钟内请求接口。

  • APISecret 可以去对接数据查询里查询

3 请求体

请求体数据类型是JSON,如果接口不需要,可以不传。

例如:{"_id":"22e25d60-809d-11e6-ad5a-b7e3030127fb"}

4 情景举例

需求:查询历史工单记录

例如:

用户账号:N00000000556

当前时间:20161013164303

APISecret: 123456

Authorization: "TjAwMDAwMDAwNTU2OjIwMTYxMDEzMTY0MzAz"

sig:"AED8764EFF64286C14E1F26648FF140F"

请求方式: POST

URL: http://apis.7moor.com/v20170704/business/handleBusiness/N00000000556 ?sig=AED8764EFF64286C14E1F26648FF140F

请求头:

Content-Type:application/json;charset=utf-8;
Authorization: TjAwMDAwMDAwNTU2OjIwMTYxMDEzMTY0MzAz;

请求体:

{
    "number": "2020070700001",
    "flow": "",
    "beginCreateTime": "2020-06-14 23:59:59",
    "endCreateTime": "2020-07-13 23:59:59",
    "beginLastUpdateTime": "",
    "endLastUpdateTime": "2020-07-14",
    "historyStartTime": "2020-06-13 23:59:59",
    "historyEndTime": "2020-07-14 23:59:59",
    "page": 1,
    "pageSize": 200
}


请求成功返回:

{
"code": 200,
"message": "success!",
"totalCount": 1,
"data": [
    {
        "_id": "0c6753e0-c001-11ea-872e-3785eca9b7a7",
        "number": "2020070700001",
        "flow": "f2dbf4e0-d2ac-11e9-a569-c5359b9a58f5",
        "flowName": "请假申请",
        "status": "dealing",
        "priority": "紧急",
        "createUser": "1234",
        "createTime": "2020-07-07 11:22:12",
        "lastUpdateTime": "2020-07-09 11:38:26",
        "customer": "79a67370-a187-11ea-a279-dfd3fd9ce306",
        "customerName": "111112222",
        "totalDuration": 0,
        "history": [
            {
                "master": "1234",
                "excuteUser": "4321",
                "fromStep": "审核申请",
                "step": "填写申请",
                "backInfo": "哒哒哒哒哒哒",
                "duration": {
                    "stayDuration": "21 h 21 m 51 s"
                },
                "time": "2020-07-09 11:38:26",
                "action": "backIn"
            },
            {
                "master": "1234",
                "step": "审核申请",
                "backInfo": "水水水水",
                "attach": [],
                "time": "2020-07-08 14:16:35",
                "action": "comment"
            },
            {
                "master": "1234",
                "info": "工单优先级由【普通】调整为【紧急】",
                "excuteUser": "1234",
                "time": "2020-07-08 14:14:29",
                "action": "changePriority"
            },
            {
                "master": "1234",
                "trigger": "审核申请-触发器通知",
                "info": "分配给座席【4321】",
                "time": "2020-07-07 11:22:12",
                "action": "triggerAssign"
            },
            {
                "master": "1234",
                "excuteUser": "",
                "fromStep": "填写申请",
                "step": "审核申请",
                "data": {},
                "duration": {},
                "time": "2020-07-07 11:22:12",
                "action": "transformIn"
            },
            {
                "master": "1234",
                "excuteUser": "",
                "step": "填写申请",
                "data": {
                    "b-土地": "地球-->中国-->北京",
                    "c-土地": "学校1-->班级1-1",
                    "申请人": "111112222"
                },
                "time": "2020-07-07 11:22:12",
                "action": "create"
            }
        ]
    }
  ]
}

鉴权失败返回:

{
    "message": "Forbidden",
    "code": 403
}

鉴权成功,请求体参数错误返回:

{
    "code": 400,
    "message": "please check your parameters"
}

示例代码:(以查询坐席状态接口为例)

NodeJS示例代码 apiDemo/demo.js

JAVA示例代码 apiDemo/src/com/m7/restapi/demo/ApiDemo.java

php示例代码 moor.php

asp示例代码 Moor.net

鉴权参数生成工具:秘钥生成器