- 积分
- 322
- 金钱
- 289
- 威望
- 0
- 贡献
- 0
- HASS币
- 0
中级会员
挖煤的猫
- 积分
- 322
- 金钱
- 289
- HASS币
- 0
|
本帖最后由 yueqiumao 于 2019-8-28 12:10 编辑
由于经常要点外卖,不想老拿手机看外卖啥时候送到,索性就想能不能直接把订单信息接到小红里,快到的时候通过微信发送个通知。
1.API分析
分析了下饿了么网页版,发现有api可以使用,而且非常简单。
用户认证,在网页版登录后,会生成一个名字为 SID 的 Cookie 参数,这个就是认证的关键了,而且一次登录长期有效,由于比较懒就不处理登录这块逻辑了,直接在浏览器登录并提取这个值。
登录地址
https://www.ele.me/home/
获取用户uid
https://www.ele.me/restapi/eus/v2/current_user
这个api可以获取到用户的uid,下面获取订单的api需要用到
获取订单列表
https://www.ele.me/restapi/bos/v2/users/<uid>/orders?limit=10&offset=0
这个api需要替换 uid 为自己当前的 uid,通过它可以获取到最近一段时间的订单列表信息。通过参数 limit 和 offset 可以控制返回的订单数量与位置。结果是以数组的形式返回,数组每一个元素都是一个 order 对象。
2.小红接入
[{"id":"ff252ccf.9d5788","type":"inject","z":"6789e3f5.e9b0bc","name":"","topic":"","payload":"","payloadType":"date","repeat":"60","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":60,"wires":[["a17d8713.c1baf8"]]},{"id":"a17d8713.c1baf8","type":"change","z":"6789e3f5.e9b0bc","name":"配置SID Cookie","rules":[{"t":"set","p":"cookies","pt":"msg","to":"{\"SID\":\"你的SID\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":220,"y":120,"wires":[["927c9c95.c85368"]]},{"id":"927c9c95.c85368","type":"http request","z":"6789e3f5.e9b0bc","name":"获取uid","method":"GET","ret":"txt","paytoqs":false,"url":"https://www.ele.me/restapi/eus/v2/current_user","tls":"","proxy":"","authType":"","x":200,"y":180,"wires":[["2d2eb754.d6eae8"]]},{"id":"2d2eb754.d6eae8","type":"change","z":"6789e3f5.e9b0bc","name":"","rules":[{"t":"set","p":"uid","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":210,"y":240,"wires":[["2c240421.641d9c"]]},{"id":"2c240421.641d9c","type":"http request","z":"6789e3f5.e9b0bc","name":"","method":"GET","ret":"obj","paytoqs":false,"url":"https://www.ele.me/restapi/bos/v2/users/{{uid}}/orders?limit=10&offset=0","tls":"","proxy":"","authType":"","x":200,"y":300,"wires":[["f59706fe.f164"]]},{"id":"f59706fe.f164","type":"change","z":"6789e3f5.e9b0bc","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.basket.group.name","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":360,"wires":[["e8a11906.309e6"]]},{"id":"e8a11906.309e6","type":"debug","z":"6789e3f5.e9b0bc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":190,"y":420,"wires":[]}]
到此结束,由于比较懒快送达的通知有空再继续,,,
|
|