- 积分
- 484
- 金钱
- 443
- 威望
- 0
- 贡献
- 0
- HASS币
- 0
中级会员
- 积分
- 484
- 金钱
- 443
- HASS币
- 0
|
发表于 2023-6-5 15:27:55
|
显示全部楼层
加个JSON节点,之后msg.payload.data.token就是的了,,我模拟着写了一个,附上流,最后一个DEBUG的payload.data.items[0].public_url 这个0是第一个数组,你要取哪个就改一下,再就是改登陆邮箱和密码
[
{
"id": "c6f6577aa1cff8ee",
"type": "function",
"z": "20213920515a31f2",
"name": "function 34",
"func": "msg.method = \"POST\";\nmsg.headers = {\n \"Accept\": \"application/json, text/plain, */*\",\n \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36\",\n \"Content-Type\": \"application/json;charset=UTF-8\",\n \"Origin\": \"http://192.168.1.62:9200\",\n \"Referer\": \"http://192.168.1.62:9200/\",\n \"Accept-Language\": \"zh-CN,zh;q=0.9,en;q=0.8\", \"Pragma\": \"no-cache\", \"Cache-Control\": \"no-cache\"\n};\n\nmsg.payload = { \"email\": \"[email protected]\", \"password\": \"aaaaa\" };\n\nmsg.url = \"http://192.168.1.62:9200/api/v1/user/login\";\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 350,
"y": 3320,
"wires": [
[
"4693f89553552391"
]
]
},
{
"id": "4693f89553552391",
"type": "www-request",
"z": "20213920515a31f2",
"name": "",
"method": "use",
"ret": "txt",
"url": "",
"follow-redirects": true,
"persistent-http": true,
"tls": "",
"x": 540,
"y": 3320,
"wires": [
[
"1caf9586d6d74c5e"
]
]
},
{
"id": "3013f03f6a8182d0",
"type": "inject",
"z": "20213920515a31f2",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 140,
"y": 3300,
"wires": [
[
"c6f6577aa1cff8ee"
]
]
},
{
"id": "1caf9586d6d74c5e",
"type": "json",
"z": "20213920515a31f2",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 690,
"y": 3320,
"wires": [
[
"5dcf57fb31415983"
]
]
},
{
"id": "5dcf57fb31415983",
"type": "function",
"z": "20213920515a31f2",
"name": "function 35",
"func": "const token = msg.payload.data.token;\nnode.error(token, msg);\nmsg.method = \"GET\";\nmsg.headers = {\n \"Accept\": \"application/json, text/plain, */*\",\n \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36\",\n \"Content-Type\": \"application/json;charset=UTF-8\",\n \"Origin\": \"http://192.168.1.62:9200\",\n \"Referer\": \"http://192.168.1.62:9200/\",\n \"Authorization\": \"Bearer \" + token,\n \"Accept-Language\": \"zh-CN,zh;q=0.9,en;q=0.8\",\n \"Pragma\": \"no-cache\",\n \"Cache-Control\": \"no-cache\"\n};\n\n\nmsg.url = \"http://192.168.1.62:9200/api/v1/tunnels\";\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 210,
"y": 3400,
"wires": [
[
"7224167a296d2b83"
]
]
},
{
"id": "7224167a296d2b83",
"type": "www-request",
"z": "20213920515a31f2",
"name": "",
"method": "use",
"ret": "txt",
"url": "",
"follow-redirects": true,
"persistent-http": true,
"tls": "",
"x": 410,
"y": 3400,
"wires": [
[
"8213a6945cdb2928"
]
]
},
{
"id": "8213a6945cdb2928",
"type": "json",
"z": "20213920515a31f2",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 550,
"y": 3400,
"wires": [
[
"2a1c6de2d30f1434"
]
]
},
{
"id": "2a1c6de2d30f1434",
"type": "debug",
"z": "20213920515a31f2",
"name": "debug 16",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload.data.items[0].public_url",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 740,
"y": 3400,
"wires": []
}
] |
评分
-
查看全部评分
|