当前位置: 首页 > news >正文

智慧卫生间

智慧卫生间

    • 获取ApiKey/SecretKey
    • 获取Access_token
    • 获取卫生间实时数据
    • 返回说明

获取ApiKey/SecretKey

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

获取Access_token

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

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

例如:

#pythonimport requestsurl = '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'))

获取卫生间实时数据

向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())

·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'}
]

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

http://www.lryc.cn/news/234328.html

相关文章:

  • Cadence virtuoso drc lvs pex 无法输入
  • 反序列化漏洞(2), 分析调用链, 编写POC
  • Pytorch reshape用法
  • Latex 辅助写作工具
  • frp新版本frp_0.52.3设置
  • 100G.的DDoS高防够用吗?
  • 【django+vue】项目搭建、解决跨域访问
  • 【数据库】数据库连接池导致系统吞吐量上不去-复盘
  • 华纳云:租用的服务器连接超时怎么办?
  • 基于MS16F3211芯片的触摸控制灯的状态变化和亮度控制(11.17,PWM)
  • 编译buildroot出错,这个怎么解决呢,感谢
  • 【0基础学Java第十课】-- 认识String类
  • lxml基本使用
  • 【数据结构初阶】链表OJ
  • 【Vue渲染】 条件渲染 | v-if | v-show | 列表渲染 | v-for
  • 开源网安解决方案荣获四川数实融合创新实践优秀案例
  • debian/ubuntu/linux如何快速安装vscode
  • Python3语法总结-数据转换②
  • 【火炬之光-魔灵装备】
  • javascript选择器的封装,只需要写元素名或css类及id都可以选择到元素
  • 机器学习第7天:逻辑回归
  • 努力奋斗,遇上对的人
  • 基于单片机音乐弹奏播放DS1302万年历显示及源程序
  • ceph学习笔记
  • SQLSERVER 遍历循环的两种方式很详细有源码(2)
  • flutter背景图片设置
  • 【运维 监控】Grafana + Prometheus,监控Linux
  • Sentinel底层原理(下)
  • 竞赛选题 疫情数据分析与3D可视化 - python 大数据
  • macos 配置ndk环境