说明

本文档主要用于针对接口签名和对应接口请求参数下发,做相关示例,以供参考。

MQTT接口,实际签名和V2的一致,只是请求参数的时候多了"Route""RequestId"
  • 以【查询车场区域信息】接口为例

1、假设下面为要请求的数据:

{
    "ParkKey": "{{parkkey}}",
    "AppId": "{{appid}}",
    "TimeStamp": "{{timestamp}}",
    "Nonce": "owekhjgzkosy",
    "Sign": "pezgzflbnbrwwcdadjajvphz",
    "Route": "AreaQuery",
    "RequestId": "12345665",
    "Data": {
        "PageIndex": 1,
        "PageSize": 25,
        "OrderBy": "Uid",
        "OrderType": 0,
        "QueryCondition": [
        ]
    }
}

2、先将Data里面的内容,进行ASCII码从小到大排序(升序)后转换为字符串(转换小写)

orderby=uid&ordertype=0&pageindex=1&pagesize=25&querycondition=

3、再将排序好的数据,进行MD5加密,参考第三方在线网站:https://www.sojson.com/encrypt_md5.html

那么date的数据,通过MD5加密后的数据为:

0a78297be1cf12b1faf9efa8b74f1c5e

4、将准备好的参数进行拼接生成字符串:AppIdParkKeyTimeStampNonceData

appid=fvytu5eq&data=0a78297be1cf12b1faf9efa8b74f1c5e&parkkey=1726313394251322&timestamp=1728559158205&nonce=836867

5、将步骤4生成的字符串,转成小写,并使用HMAC-SHA256算法进行签名,密钥为第三方服务AppSecret,得到的结果就是我们需要的签名。参考第三方在线网站:https://www.mklab.cn/utils/hmac

0pv/bitn6cuvogmlg8xtgniuytiealcy5fkxtgy7wci=

6、然后将RequestIdRoute放进去,请求接口即可。

{
    "ParkKey": "1726313394251322",
    "AppId": "fvytu5eq",
    "TimeStamp": "1728559158205",
    "Nonce": "836867",
    "Sign": "0pv/bitn6cuvogmlg8xtgniuytiealcy5fkxtgy7wci=",
    "Route": "AreaQuery",
    "RequestId": "12345665",
    "Data": {
        "PageIndex": 1,
        "PageSize": 25,
        "OrderBy": "Uid",
        "OrderType": 0,
        "QueryCondition": []
    }
}

返回数据:

{
    "ResultCode": 200,
    "ResultMsg": "查询数据成功!",
    "ResultId": null,
    "Data": {
        "PageIndex": 1,
        "PageSize": 25,
        "TotalCount": 2,
        "Results": [
            {
                "Uid": 1,
                "No": "1726313394367527",
                "AreaName": "外场",
                "AreaType": 0,
                "AreaSpaceNum": 63,
                "PUid": 0,
                "Level": 0,
                "CreationTime": "2024-10-07 14:16:36"
            },
            {
                "Uid": 2,
                "No": "1728281625923837",
                "AreaName": "内场",
                "AreaType": 1,
                "AreaSpaceNum": 500,
                "PUid": 1,
                "Level": 1,
                "CreationTime": "2024-10-07 14:16:36"
            }
        ]
    }
}
作者:mry  创建时间:2024-10-10 19:09
最后编辑:mry  更新时间:2025-01-22 09:07