完整的微信登陆 接收消息流程
1. GET获取uuid = "YbnMBIWGuQ=="; https://login.weixin.qq.com/jslogin? appid=wx782c26e4c19acffb &redirect_uri=https%3A%2F%2Fwx.qq.com%2Fcgi-bin%2Fmmwebwx-bin%2Fwebwxnewloginpage &fun=new &lang=zh_CN &_=1455976107974 参数: _ 1455976107974 appid wx782c26e4c19acffb fun new lang zh_CN redirect_uri https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage "https://login.weixin.qq.com/jslogin? appid=wx782c26e4c19acffb&redirect_uri=https%3A%2F%2Fwx.qq.com%2Fcgi-bin%2Fmmwebwx-bin%2Fwebwxnewloginpage &fun=new&lang=zh_CN&_=$now"; 响应; window.QRLogin.code = 200; window.QRLogin.uuid = "YbnMBIWGuQ=="; 2.GET 获取验证码: https://login.weixin.qq.com/qrcode/YbnMBIWGuQ== 响应内容为2维码: 3. https://login.weixin.qq.com/cgi-bin/mmwebwx-bin/login?loginicon=true &uuid=YbnMBIWGuQ== &tip=1 &r=17804603&_=1455976107975 返回201 请在手机上点击微信登陆 window.code=201;window.userAvatar = \'data:img/jpg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QAIRXhpZgAA/9sAQwADAgIDAgIDAwMDBAMDBAUIBQUEBAUKBwcGCAwKDAwLCgsLDQ4SEA0OEQ4LCxAWEBETFBUVFQwPFxgWFBgSFBUU /9sAQwEDBAQFBAUJBQUJFA0LDRQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU/8AAEQgAhACEAwEiAAIRAQMRAf 点击微信登陆后把 my $show_tip = 0; 修改为0 4. https://login.weixin.qq.com/cgi-bin/mmwebwx-bin/login?loginicon=true &uuid=YbnMBIWGuQ== &tip=0&r=17798624&_=1455976107976 这时候 &tip=0 响应: 返回登陆URL window.code=200; window.redirect_uri="https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage?ticket=AV0WBWy8bPjtZXRUFfA-Ak42 @qrticket_0&uuid=YbnMBIWGuQ==&lang=zh_CN&scan=1455976124"; 获取 $ticket=$1;$user = $4;供下面使用 5. https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage?ticket=AV0WBWy8bPjtZXRUFfA-Ak42@qrticket_0 &uuid=YbnMBIWGuQ== &lang=zh_CN &scan=1455976124&fun=new&version=v2&lang=zh_CN 返回: <error><ret>0</ret><message>OK</message><skey>@crypt_597aeefd_799f8b97addd5b75d3e024c3be3d5a3c</skey ><wxsid>49Gd9tu26g+mfnIF</wxsid><wxuin>1284510822</wxuin><pass_ticket>VXYCUzf9EtGRYpu6tWwMlPwlbXJtc7XkB2U3oK9jRtI2ECSNkG %2FGCQJaHtLI8EmD</pass_ticket><isgrayscale>1</isgrayscale></error> 状态为<ret>0,表示登陆成功 "https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage?ticket=$ticket &uuid=$uuid&lang=zh_CN&scan=$user&fun=new&version=v2&lang=zh_CN"; 获取下面需要的信息: $Skey = $1; $wxsid = $2; $wxuin = $3; $pass_ticket = $4; 6.POST 获取最新的聊天群和好友信息: https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxinit?r=17805322 &lang=zh_CN &pass_ticket=VXYCUzf9EtGRYpu6tWwMlPwlbXJtc7XkB2U3oK9jRtI2ECSNkG%252FGCQJaHtLI8EmD 返回信息包含了自己微信号的信息: "User": { "Uin": 1284510822, "UserName": "@f19b919ec646f564c688b337f13f35f9db491a1477db86dceaebdef5263f682b", "NickName": "赵杨健", "HeadImgUrl": "/cgi-bin/mmwebwx-bin/webwxgeticon?seq=1052381104&username=@f19b919ec646f564c688b337f13f35f9db491a1477db86dceaebdef5263f682b&skey=@crypt_597aeefd_799f8b97addd5b75d3e024c3be3d5a3c", "RemarkName": "", "PYInitial": "", "PYQuanPin": "", "RemarkPYInitial": "", "RemarkPYQuanPin": "", "HideInputBarFlag": 0, "StarFriend": 0, "Sex": 1, "Signature": "", "AppAccountFlag": 0, "VerifyFlag": 0, "ContactFlag": 0, "WebWxPluginSwitch": 0, "HeadImgFlag": 1, "SnsFlag": 49 } 其他信息如下: { "BaseResponse": { "Ret": 0, "ErrMsg": "" } , "Count": 11, "ContactList": [{ "Uin": 0, "UserName": "filehelper", "NickName": "文件传输助手", "HeadImgUrl": "/cgi-bin/mmwebwx-bin/webwxgeticon?seq=647236593&username=filehelper&skey=@crypt_597aeefd_799f8b97addd5b75d3e024c3be3d5a3c", "ContactFlag": 3, "MemberCount": 0, "MemberList": [], 请求参数: lang zh_CN pass_ticket VXYCUzf9EtGRYpu6tWwMlPwlbXJtc7XkB2U3oK9jRtI2ECSNkG%2FGCQJaHtLI8EmD r 17805322 Post: BaseRequest Object { Uin="1284510822", Sid="49Gd9tu26g+mfnIF", Skey="@crypt_597aeefd_799f8b97addd5b75d3e024c3be3d5a3c", 更多...} DeviceID "e239089144319510" Sid "49Gd9tu26g+mfnIF" Skey "@crypt_597aeefd_799f8b97addd5b75d3e024c3be3d5a3c" Uin "1284510822" 6. 获取好友信息: https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgetcontact?lang=zh_CN &pass_ticket=VXYCUzf9EtGRYpu6tWwMlPwlbXJtc7XkB2U3oK9jRtI2ECSNkG%252FGCQJaHtLI8EmD &r=1455976116515&seq=0 &skey=@crypt_597aeefd_799f8b97addd5b75d3e024c3be3d5a3c "https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgetcontact?lang=zh_CN&pass_ticket=$pass_ticket&seq=0&skey=$skey"; 7.批量获取群和好友信息: https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxbatchgetcontact?type=ex&r=1455976116566 &lang=zh_CN &pass_ticket=VXYCUzf9EtGRYpu6tWwMlPwlbXJtc7XkB2U3oK9jRtI2ECSNkG%252FGCQJaHtLI8EmD 参数信息: lang zh_CN pass_ticket VXYCUzf9EtGRYpu6tWwMlPwlbXJtc7XkB2U3oK9jRtI2ECSNkG%2FGCQJaHtLI8EmD r 1455976116566 type ex JSON: BaseRequest Object { Uin=1284510822, Sid="49Gd9tu26g+mfnIF", Skey="@crypt_597aeefd_799f8b97addd5b75d3e024c3be3d5a3c", 更多...} DeviceID "e925236390791638" Sid "49Gd9tu26g+mfnIF" Skey "@crypt_597aeefd_799f8b97addd5b75d3e024c3be3d5a3c" Uin 1284510822 Count 14 List [Object { UserName="@@3fc7e542abdffbd6199089...ff9a0deba906cdf955c4d5f", EncryChatRoomId=""}, Object { UserName="@@037634c552d4cd89b8dda4...50001641a1fb7856a645c49", EncryChatRoomId=""}, Object { UserName="@@2cb5910c6bdbcbc25bcb62...4978e1650b80f03c8f03c31", EncryChatRoomId=""}, 11 更多...] 0 Object { UserName="@@3fc7e542abdffbd6199089...ff9a0deba906cdf955c4d5f", EncryChatRoomId=""} 1 Object { UserName="@@037634c552d4cd89b8dda4...50001641a1fb7856a645c49", EncryChatRoomId=""} 2 Object { UserName="@@2cb5910c6bdbcbc25bcb62...4978e1650b80f03c8f03c31", EncryChatRoomId=""} 3 Object { UserName="@@5d3fad08dcd942e7725c24...e576d572e70aff9dbca63e3", EncryChatRoomId=""} 4 Object { UserName="@@700c0bee86abd26519473e...e3b3601c174342bb5ca84b1", EncryChatRoomId=""} 5 Object { UserName="@@1ff079a7fa4b77e7177a75...15cb47857014d6c5e68ed2e", ChatRoomId=""} 6 Object { UserName="@@05a8590a07bed0bd7c618f...d7df919c5a10d0b35872dfb", ChatRoomId=""} 7 Object { UserName="@@27c08b51d6bf9f7013275b...bf1e52e2faf20521f3e0849", ChatRoomId=""} 8 Object { UserName="@@d6e41a8ed067535ce1b682...35c092618ebbf9a68159c73", ChatRoomId=""} 9 Object { UserName="@@50c09f59336e66d3749ed8...22cb0bbff9d22d0c2960935", ChatRoomId=""} 10 Object { UserName="@@eeb117cb9ba69a717d9367...3063dd510ade0c61d070f22", ChatRoomId=""} 11 Object { UserName="@@b2553f1259fe487b2815eb...e58e63e0f50db2eab55e762", ChatRoomId=""} 12 Object { UserName="@dd78d493fbc5f370000f48776f1f589c", EncryChatRoomId=""} 13 Object { UserName="@662a23ec09f2d6960599d13...7ce798f2a6d73696c7e0548", EncryChatRoomId=""} 8.synccheck 和webwxsync 关系: https://webpush.weixin.qq.com/cgi-bin/mmwebwx-bin/synccheck?r=1455976116542 &skey=%40crypt_597aeefd_799f8b97addd5b75d3e024c3be3d5a3c&sid=49Gd9tu26g%2BmfnIF&uin=1284510822&deviceid=e505497928342414& synckey=1_647250865%7C2_647251630%7C3_647251553%7C1000_1455964279&_=1455976107977 window.synccheck={retcode:"0",selector:"2"} selector:"2" 不等于0 说明有消息: POST 参数: BaseRequest Object { Uin=1284510822, Sid="49Gd9tu26g+mfnIF", Skey="@crypt_597aeefd_799f8b97addd5b75d3e024c3be3d5a3c", 更多...} DeviceID "e282179384590658" Sid "49Gd9tu26g+mfnIF" Skey "@crypt_597aeefd_799f8b97addd5b75d3e024c3be3d5a3c" Uin 1284510822 SyncKey Object { Count=4, List=[4]} Count 4 List [Object { Key=1, Val=647250865}, Object { Key=2, Val=647251630}, Object { Key=3, Val=647251553}, Object { Key=1000, Val=1455964279}] 0 Object { Key=1, Val=647250865} 1 Object { Key=2, Val=647251630} 2 Object { Key=3, Val=647251553} 3 Object { Key=1000, Val=1455964279} rr 17796470 https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxsync?sid=49Gd9tu26g+mfnIF &skey=@crypt_597aeefd_799f8b97addd5b75d3e024c3be3d5a3c&lang=zh_CN &pass_ticket=VXYCUzf9EtGRYpu6tWwMlPwlbXJtc7XkB2U3oK9jRtI2ECSNkG%252FGCQJaHtLI8EmD 返回; "ContinueFlag": 0, "SyncKey": { "Count": 8, "List": [{ "Key": 1, "Val": 647250865 } ,{ "Key": 2, "Val": 647251632 } ,{ "Key": 3, "Val": 647251553 } ,{ "Key": 11, "Val": 647251567 } ,{ "Key": 13, "Val": 647230079 } ,{ "Key": 201, "Val": 1455976126 } ,{ "Key": 203, "Val": 1455953440 } ,{ "Key": 1000, "Val": 1455964279 } ] } , "SKey": "" } 下一次synccheck的时候: https://webpush.weixin.qq.com/cgi-bin/mmwebwx-bin/synccheck?r=1455976118181 &skey=%40crypt_597aeefd_799f8b97addd5b75d3e024c3be3d5a3c &sid=49Gd9tu26g%2BmfnIF&uin=1284510822&deviceid=e425328821813021 &synckey= 1_647250865%7C 2_647251632%7C 3_647251553%7C 11_647251567%7C 13_647230079%7C 201_1455976126%7C 203_1455953440%7C 1000_1455964279 &_=1455976107978 synckey 1_647250865|2_647251632|3_647251553|11_647251567|13_647230079|201_1455976126|203_1455953440|1000_145
版权声明:本文为zhaoyangjian724原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。