【抓取阿特兹(my mazda App)汽车状态】通过node-red-contrib-bizwechat(企业微信推送)

新手首贴,大神忽略

如何使用node-red-contrib-bizwechat
请先看教程:基于企业微信的一对多消息送达服务-完美替代pushbear

需先注册my mazda 账号

第一步:通过fiddler(使用方法自行百度)抓取app请求接口参数:

第二步:编写node-red脚本(部分参数根据抓包结果修改):

[{"id":"f77e07dc.73b7c8","type":"tab","label":"抓取汽车状态信息","disabled":false,"info":""},{"id":"cc7df7e7.f930d8","type":"http request","z":"f77e07dc.73b7c8","name":"获取token","method":"POST","ret":"obj","paytoqs":false,"url":"https://mazda.palmgo.cn:8443/mazda-prod/mobile-api/oauth2/token","tls":"","proxy":"","authType":"","x":800,"y":200,"wires":[["523ed5de.c079cc","abe556cd.9eb478"]]},{"id":"714a20ec.3c919","type":"inject","z":"f77e07dc.73b7c8","name":"","topic":"","payload":"","payloadType":"date","repeat":"7000","crontab":"","once":true,"onceDelay":0.1,"x":440,"y":200,"wires":[["9f7ea978.751d18"]]},{"id":"523ed5de.c079cc","type":"debug","z":"f77e07dc.73b7c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1030,"y":60,"wires":[]},{"id":"9f7ea978.751d18","type":"function","z":"f77e07dc.73b7c8","name":"设置请求头","func":"// 请求参数,取抓包https://mazda.palmgo.cn:8443/mazda-prod/mobile-api/oauth2/token 接口请求参数\nmsg.payload = \"\";\nmsg.headers = {};\nmsg.headers['Content-Type'] = 'application/json;charset=UTF-8';\nmsg.headers['Connection'] = 'keep-alive';\nmsg.headers['User-Agent'] = 'My%20Mazda/138 CFNetwork/1179.0.1 Darwin/20.0.0';\nmsg.headers['Accept-Language'] = 'zh-cn';\nmsg.headers['Accept-Encoding'] = 'gzip, deflate, br';\nreturn msg;","outputs":1,"noerr":0,"x":610,"y":200,"wires":[["cc7df7e7.f930d8"]]},{"id":"abe556cd.9eb478","type":"function","z":"f77e07dc.73b7c8","name":"保存token","func":"global.set('mzd_access_token', msg.payload.access_token)\nmsg.deldy = 7000;\nreturn msg;","outputs":1,"noerr":0,"x":1020,"y":200,"wires":[[]]},{"id":"7c367a91.df0804","type":"function","z":"f77e07dc.73b7c8","name":"设置请求头","func":"// 请求参数,取抓包https://mazda.palmgo.cn:8443/mazda-prod/mobile-api/accountMazda/login接口请求参数\nmsg.payload = \"\";\nmsg.headers = {};\nmsg.headers['Content-Type'] = 'application/json;charset=UTF-8';\nmsg.headers['Connection'] = 'keep-alive';\nmsg.headers['User-Agent'] = 'Mazda/1.0.3 (iPhone; iOS 14.0; Scale/2.00)';\nmsg.headers['Accept-Language'] = 'zh-cn';\nmsg.headers['Accept-Encoding'] = 'gzip, deflate, br';\nmsg.headers['Authorization'] = 'Bearer '+global.get(\"mzd_access_token\");\n\nreturn msg;","outputs":1,"noerr":0,"x":610,"y":380,"wires":[["2bacf1f9.d3bfae"]]},{"id":"2bacf1f9.d3bfae","type":"http request","z":"f77e07dc.73b7c8","name":"用户登录","method":"POST","ret":"obj","paytoqs":false,"url":"https://mazda.palmgo.cn:8443/mazda-prod/mobile-api/accountMazda/login","tls":"","proxy":"","authType":"","x":800,"y":380,"wires":[["545afc08.2c5e54","e4d5c336.630c8"]]},{"id":"545afc08.2c5e54","type":"function","z":"f77e07dc.73b7c8","name":"保存token","func":"global.set('mzd_token', msg.payload.data.token)\nreturn msg;","outputs":1,"noerr":0,"x":1020,"y":380,"wires":[["b48318f1.a5b838"]]},{"id":"e4d5c336.630c8","type":"debug","z":"f77e07dc.73b7c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1030,"y":300,"wires":[]},{"id":"b2e6178.36de0e8","type":"comment","z":"f77e07dc.73b7c8","name":"动态刷新access_token信息","info":"","x":490,"y":160,"wires":[]},{"id":"6c928107.6616f","type":"comment","z":"f77e07dc.73b7c8","name":"登录用户操作","info":"","x":410,"y":360,"wires":[]},{"id":"767e3c24.0f60e4","type":"comment","z":"f77e07dc.73b7c8","name":"获取汽车位置信息","info":"","x":470,"y":520,"wires":[]},{"id":"ba505f41.bf8db","type":"inject","z":"f77e07dc.73b7c8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":430,"y":560,"wires":[["b48318f1.a5b838"]]},{"id":"b48318f1.a5b838","type":"function","z":"f77e07dc.73b7c8","name":"设置请求头","func":"// 请求参数,取抓包https://mazda.palmgo.cn:8443/mazda-prod/mobile-api/vehicleData/findMyCarStatus接口请求参数\nmsg.payload = \"\";\nmsg.headers = {};\nmsg.headers['Content-Type'] = 'application/json;charset=UTF-8';\nmsg.headers['Connection'] = 'keep-alive';\nmsg.headers['User-Agent'] = 'Mazda/1.0.3 (iPhone; iOS 14.0; Scale/2.00)';\nmsg.headers['Accept-Language'] = 'zh-cn';\nmsg.headers['Accept-Encoding'] = 'gzip, deflate, br';\nmsg.headers['Authorization'] = 'Bearer '+global.get(\"mzd_access_token\");\nmsg.headers['token'] = global.get(\"mzd_token\");\n// 手机号\nmsg.headers['identifier'] = 'xxxx';\n\nreturn msg;","outputs":1,"noerr":0,"x":610,"y":560,"wires":[["3d10ac68.4ac874"]]},{"id":"3d10ac68.4ac874","type":"http request","z":"f77e07dc.73b7c8","name":"获取车辆状态信息","method":"POST","ret":"obj","paytoqs":false,"url":"https://mazda.palmgo.cn:8443/mazda-prod/mobile-api/vehicleData/findMyCarStatus","tls":"","proxy":"","authType":"","x":830,"y":560,"wires":[["f76d40fe.05f41","479b7c09.28f994"]]},{"id":"f76d40fe.05f41","type":"debug","z":"f77e07dc.73b7c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1750,"y":460,"wires":[]},{"id":"3ae85be1.f0bc94","type":"comment","z":"f77e07dc.73b7c8","name":"其他状态描述","info":"doorStatus(车门状态):\n1.右车门-00000010","x":450,"y":620,"wires":[]},{"id":"eb50a04d.c06a9","type":"function","z":"f77e07dc.73b7c8","name":"保存值","func":"let info = msg.carstatus.data;\nlet location = msg.payload.location;\n// 驻车状态:1-是\nlet parkingBrake = info.realtimeInfo.parkingBrake;\n// 雨刷控制:00000011自动\nlet pluviometer = info.realtimeInfo.pluviometer;\n// 发动机状态:3-熄火\nlet engineStatus = info.realtimeInfo.engineStatus;\n// 前照灯状态:3-近光灯开启\nlet headlightStatus = info.realtimeInfo.headlightStatus; \n// 制动状态:0-未制动\nlet brakeStatus = info.realtimeInfo.brakeStatus;\n// 门状态:00000010(右门)\nlet doorStatus = info.realtimeInfo.doorStatus;\n// | 纵向 - ${info.realtimeInfo.acceleratedVelocityLengthways} | 横向 - ${info.realtimeInfo.acceleratedVelocityCrosswise} \n// | 加速器范围 | ${info.realtimeInfo.acceleratorExtent} \n// | 柴油损耗   | ${info.realtimeInfo.dieselLose}\nmsg.payload = `\n* 汽车位置\n| 熄火时间   | ${info.locationInfo.reportTimeString} \n| 停车位置   | ${location} \n* 汽车状态\n| 行驶公里数 | ${info.realtimeInfo.mile} km \n| 是否驻车   | ${parkingBrake} \n| 车轮转速   | ${info.realtimeInfo.wheelSpeed} \n| 雨刷控制   | ${pluviometer} \n| 发动机状态 | ${engineStatus} \n| 转速       | ${info.realtimeInfo.rotateSpeed} \n| 档位       | ${info.realtimeInfo.gears} \n| 座位压力   | ${info.realtimeInfo.pressureCopilot} \n| 制动状态   | ${brakeStatus} \n| 门状态     | ${doorStatus} \n| 汽油残渣   | ${info.realtimeInfo.gasolineResidue} \n| 电压       | ${info.realtimeInfo.voltage} \n| 气囊状态   | ${info.realtimeInfo.airSacStatus} \n| 制动压力   | ${info.realtimeInfo.brakePressure} \n| 纵向加速   | ${info.realtimeInfo.acceleratedVelocityLengthways} \n| 横向加速   | ${info.realtimeInfo.acceleratedVelocityCrosswise} \n| 主驾安全带 | ${info.realtimeInfo.safetyBeltDriver} \n| 副驾安全带 | ${info.realtimeInfo.safetyBeltCopilot} \n| 加速器范围 | ${info.realtimeInfo.acceleratorExtent} \n| 柴油损耗   | ${info.realtimeInfo.dieselLose}\n `\nreturn msg;","outputs":1,"noerr":0,"x":1330,"y":560,"wires":[["c1451a22.39cdb8","f76d40fe.05f41"]]},{"id":"c1451a22.39cdb8","type":"bizwechat-pushbear","z":"f77e07dc.73b7c8","name":"汽车情况","bizwechat":"c25f0536.a6b868","touser":"xxxx","toparty":"","title":"汽车情况","description":"","x":1540,"y":560,"wires":[[]]},{"id":"82e60d52.645df","type":"gaode","z":"f77e07dc.73b7c8","server":"8c7ef69.7385c08","name":"获取汽车位置","longitude":"","latitude":"","x":1020,"y":740,"wires":[["eb50a04d.c06a9","f76d40fe.05f41"]]},{"id":"479b7c09.28f994","type":"function","z":"f77e07dc.73b7c8","name":"处理位置信息","func":"let longitude = msg.payload.data.locationInfo.longitude;\nlet latitude = msg.payload.data.locationInfo.latitude;\n\nlongitude = insertStr(longitude,3,'.');\nlatitude = insertStr(latitude,2,'.');\n\nmsg.payload.longitude = longitude;\nmsg.payload.latitude = latitude;\n\nmsg.carstatus = msg.payload;\n\nreturn msg;\n\nfunction insertStr(soure, start, newStr){   \n   return soure.slice(0, start) + newStr + soure.slice(start);\n}","outputs":1,"noerr":0,"x":1020,"y":660,"wires":[["82e60d52.645df"]]},{"id":"66a76948.4e4df8","type":"link in","z":"f77e07dc.73b7c8","name":"微信查询汽车状态","links":["9683b50e.6ec5c8"],"x":135,"y":380,"wires":[["5cc9a2f6.8d1b4c"]]},{"id":"409a2ac4.0bc3e4","type":"switch","z":"f77e07dc.73b7c8","name":"汽车状态查询","property":"message.Content","propertyType":"msg","rules":[{"t":"eq","v":"汽车状态","vt":"str"},{"t":"eq","v":"a","vt":"str"},{"t":"eq","v":"我的汽车","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":400,"y":420,"wires":[["7c367a91.df0804"],["7c367a91.df0804"],[]]},{"id":"5cc9a2f6.8d1b4c","type":"function","z":"f77e07dc.73b7c8","name":"解析参数","func":"msg.message.Content=msg.message.Content||msg.message.AsrContent[0]\nreturn msg;","outputs":1,"noerr":0,"x":260,"y":320,"wires":[["409a2ac4.0bc3e4","e4d5c336.630c8"]]},{"id":"c25f0536.a6b868","type":"bizwechat-configurator","z":"","name":"企业微信配置","port":"8090","corpid":"ww339bc923241f244b","agentid":"1000005","corpsecret":"gdR_c1qcp4YvqEaDXfLwCfjgajXc_19Gs7ArBV6mAto","url":"http://push.mrluo.net:99","token":"4lElCr","aeskey":"fa6XlNsOgVpcgMg5jUmJs9uQSA8shawh5Shu7V1FeTe","client_id":"GOSvdsBiE43Ejh7TEPMKleks","client_secret":"iNXfS0Cmz8runxzMiFiI2Ouh6Dvm2qGC"},{"id":"8c7ef69.7385c08","type":"gaode-server","z":"","name":"高德key","gaodeKey":""}]

效果:

那么问题来了,阿特兹哪里 :thinking:

只要 19.5k立马抱回家

这是新版阿特兹自带的吗?
用的18版阿特兹的人与车联,不知道跟这个一样不.

不知道18款有app没呢

有,叫人与车练. 测试新版阿特兹APP不通用.

自己抓包每次会生成一个类似token的长串,没搞明白怎么获取和使用 :sweat_smile: