• 智慧卫生间


    获取ApiKey/SecretKey

    ApiKey/SecretKey采用 线下获取的方式,手动分配。

    获取Access_token

    向授权服务地址http://xxxxxx:12345/token(示意)发送post请求,并在data中带上以下参数:

    ·ak: 你的ApiKey;
    ·sk: 你的SecretKey;
    ·expire_time: 有效期,单位为秒,值0为"永久";

    例如:

    #python
    
    import requests
    
    url = 'http://xxxxxx:12345/token'
    
    # 你的 API Key 和 Secret Key
    api_key = 'xxxxxxxx'
    secret_key = 'xxxxxxxx'
    expire_time = 3600  # token 的有效期(秒)
    # expire_time = 0 "永久的" 
    
    # 构建请求数据
    data = {
        'api_key': api_key,
        'secret_key': secret_key,
        'expire_time': expire_time
    }
    
    # 发送请求
    response = requests.post(url, json=data)
    
    # 打印响应
    if response.status_code == 200:
        print("Token:", response.json().get('token'))
    else:
        print("Error:", response.json().get('message'))
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27

    获取卫生间实时数据

    向API服务地址http://xxxxxx:12345/data使用POST发送请求

    请求示例:

    HTTP方法:POST

    请求URL: http://xxxxxx:12345/data

    import json
    import requests
    
    # 服务端的 URL
    url = 'http://xxxxxx:12345/data'
    
    # 假设的 Token
    token = "xxxxxxxx"
    
    
    # 构建请求头部,包含 Token
    headers = {
        'Authorization': token,
        'Content-Type': 'application/json'
    }
    
    
    # 请求的详细数据
    data = {
        'project_id': 'Project1',
        'floor': 'default',  # 可以是 'default' 或具体楼层号
        'gender': 'female'  # 可以是 'male', 'female' 或 'default'
    }
    
    # 发送请求
    response = requests.get(url, headers=headers, data=json.dumps(data) )
    
    # 输出服务端响应
    print(response.json())
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29

    ·project_id: 项目名称
    ·floor: 楼层编号,可以是 1 2 3 4 5 或者 default就是获取当前项目的所有存在的楼层, 也可以是指定多个楼层
    例如: ‘floor’: ‘1’ , ‘floor’: ‘2’ , ‘floor’: ‘2_3_5’, ‘floor’: ‘default’
    ·gender: 性别,请求男还是女或者全部请求 可以是 ‘male’, ‘female’ 或 ‘default’

    返回说明

    返回结果:

    字段类型说明
    messagestring返回Suceess或者Failed,用来判断是否请求成功
    project_idstring返回当前请求的项目名
    floorstring返回当前请求的楼层号
    genderstring返回当前请求的性别
    combined_datalist&dict返回当前请求的楼层号的厕所使用数据

    combined_data格式如下

    [
        {'floor': '3', 'signal_data': '0101010'},
        {'floor': '5', 'signal_data': '0101010'},
        {'floor': '7, 'signal_data': '0101010'}
    ]
    
    • 1
    • 2
    • 3
    • 4
    • 5

    其中
    floor代表楼层号
    signal_data代表最终数据,假设一层有7个坑位,那signal_data的长度就为7,0代表占用,1代表空闲

  • 相关阅读:
    APISpace 验证码短信API接口案例代码
    SRS流媒体服务器——Forward集群搭建和源码分析
    移动端的助农电商系统-计算机毕业设计源码08655
    java回调函数
    【ARM】UART串口与看门狗——第五篇
    【nodejs版playwright】02-支持多套测试环环境执行用例
    竞赛 深度学习 YOLO 实现车牌识别算法
    临门一脚踢不进?面试官就是不要我?程序员面试隐藏加分项你做对了吗?!
    【校招VIP】java开源框架之Zookeeper
    数据结构+java基础+进制之间的转换
  • 原文地址:https://blog.csdn.net/GottaYiWanLiu/article/details/134477962