1.打开首页,分配一个随机uuid,
2.根据该uuid获取二维码图片。
3.微信客户端扫描该图片,在客户端确认登录。
4.浏览器不停的调用一个接口,如果返回登录成功,则调用登录接口
5.此时可以获取联系人列表,可以发送消息。然后不断调用同步接口。
6.如果同步接口有返回,则可以获取新消息,然后继续调用同步接口。
源码地址:github.com/biezhi/wechat-robot
+--------------+ +---------------+ +---------------+ | | | | | | | Get UUID | | Get Contact | | Status Notify | | | | | | | +-------+------+ +-------^-------+ +-------^-------+ | | | | +-------+ +--------+ | | | +-------v------+ +-----+--+------+ +--------------+ | | | | | | | Get QRCode | | Weixin Init +------> Sync Check <----+ | | | | | | | +-------+------+ +-------^-------+ +-------+------+ | | | | | | | +-----------+ | | | +-------v------+ +-------+--------+ +-------v-------+ | | Confirm Login | | | |+------> Login +---------------> New Login Page | | Weixin Sync || | | | | | || +------+-------+ +----------------+ +---------------+| ||QRCode Scaned|+-------------+
返回数据(JSON):
{ "BaseResponse": { "Ret": 0, "ErrMsg": "" }, ...}
更多资料:
github.com/xiangzhai/qwx
github.com/Urinx/WeixinBot
www.07net01.com/2016/01/1201188.html
www.cnblogs.com/xiaozhi_5638/p/4923811.html