Files
python----/智慧校园/本地/demo.ipynb
T
admin aac9f5934d feat: 添加多个功能模块和工具脚本
- 新增websocket客户端和服务端实现
- 添加图片压缩工具和快速压缩脚本
- 实现学生信息处理相关API
- 添加MQTT客户端和消息处理功能
- 更新.gitignore忽略更多文件类型
- 添加数据库操作工具和示例
- 实现多个测试脚本和工具类
2026-04-13 14:47:50 +08:00

123 lines
3.3 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "39b16c44",
"metadata": {},
"outputs": [],
"source": [
"from requests import get,post\n",
"import time\n",
"ip = \"http://192.168.0.209:8100\"\n",
"param = {\n",
" \"username\": \"tangchao\",\n",
" \"password\": \"123456a\",\n",
" \"client_id\": \"client\",\n",
" \"grant_type\": \"password\",\n",
" \"client_secret\": \"123456\",\n",
"}\n",
"data = get(url=f\"{ip}/oauth/token?username=zhongwei&password=123456a&client_id=client&grant_type=password&client_secret=123456\").json()\n",
"token = data[\"access_token\"]\n",
"header = {\n",
" \"content-type\": \"application/json\",\n",
" \"authorization\": f\"Bearer {token}\",\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "9f7ca2db",
"metadata": {},
"outputs": [],
"source": [
"access_token = post(\"https://szihj.idsp.yunxiao.com/Open/Access/GetToken\",params={\n",
" \"corpId\": \"869376250979578017\",\n",
" \"corpSecret\": \"GQSYGTLMKNJHVLHZMHYDMHATIGTTOBYP\"\n",
" }).json()\n"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "83ed8c86",
"metadata": {},
"outputs": [],
"source": [
"token= access_token[\"access_token\"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0463e46a",
"metadata": {},
"outputs": [],
"source": [
"HttpHeaders httpHeaders = new HttpHeaders();\n",
" HttpEntity<String> httpEntity = new HttpEntity<String>(null, httpHeaders);\n",
" String url = synchronizationStudentOpenByTeamIdAndType.getAddress() + \"?corpId=\" + synchronizationStudentToken.getCorpId() + \"&corpSecret=\" + synchronizationStudentToken.getCorpSecret();\n",
" RestTemplate restTemplateHttps = new RestTemplate(RestTemplateConfig.getHttpComponentsClientHttpRequestFactory());\n",
" ResponseEntity<String> results = restTemplateHttps.exchange(url, HttpMethod.POST, httpEntity, String.class);\n",
" JSONObject json = JSON.parseObject(results.getBody());\n",
" System.out.println(\"access_token-----json-----:\"+json);"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "98f9d828",
"metadata": {},
"outputs": [],
"source": [
"header={\n",
" \"Authorization\": token\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "bc1d9df5",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'{\"errcode\":0,\"errmsg\":\"ok\",\"data\":[]}'"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"get(\"https://szihj.idsp.yunxiao.com/Open/Leave/GetLeaveList\",headers=header).text\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}