service

package
v0.0.0-...-9897aff Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2017 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckLogin

func CheckLogin(uuid string) (int64, string)

判断微信是否登陆

func DownloadImagIntoDir

func DownloadImagIntoDir(url string, dirPath string) error

下载URL指向的JPG,保存到指定路径下的qrcode.jpg文件

func GetUUIDFromWX

func GetUUIDFromWX() (string, error)

从微信服务器获取登陆uuid

func InitWX

func InitWX(loginMap *m.LoginMap) error

初始化微信登陆数据

func InviteMember

func InviteMember(loginMap *m.LoginMap, memberUserName string, chatRoomUserName string) error

邀请联系人加入群

func MapGroupInfo

func MapGroupInfo(contactMap map[string]m.User) map[string][]m.User

func NotifyStatus

func NotifyStatus(loginMap *m.LoginMap) error

*

  • 通知微信服务器状态变化,只要通知即可,无需处理返回数据
  • {"BaseRequest":{"Uin":154158775,"Sid":"/nxZxJ0LclxmOw8v","Skey":"@crypt_3aaab8d5_cdfa952ec95e594b100f44aba942a73c","DeviceID":"e390742104557152"},"Code":3,"FromUserName":"@fc96d593487db4fb92b9a633aec8293b","ToUserName":"@fc96d593487db4fb92b9a633aec8293b","ClientMsgId":1504571331980}

func ProcessLoginInfo

func ProcessLoginInfo(loginInfoStr string) (m.LoginMap, error)

*

  • 处理微信登陆成功时返回的其他登陆数据
  • 首先根据回调URI再次Get一次微信服务器,得到XML格式的登陆数据
  • 解析XML,向map中压入相关数据

func SendMsg

func SendMsg(loginMap *m.LoginMap, wxSendMsg m.WxSendMsg) error

func SyncCheck

func SyncCheck(loginMap *m.LoginMap) (int64, int64, error)

*

  • 微信心跳检查 -> 根据retcode和selector 逻辑判断是否需要拉取数据
  • Get:https://webpush.wx.qq.com/cgi-bin/mmwebwx-bin/synccheck?
  • r=1504582260660&
  • skey=%40crypt_3aaab8d5_4f38b712dd654bff65bef8406d020771&
  • sid=k4FG05I6vi26YyeW&uin=154158775&
  • deviceid=e637087162023800&
  • synckey=1_696275959%7C2_696276056%7C3_696275995%7C11_696275997%7C13_696160001%7C201_1504582232%7C203_1504580411%7C1000_1504572121%7C1001_1504572152&
  • _=1504582198153
  • 这里依然要用到Cookies *
  • 根据 https://github.com/yaphone/itchat4j/blob/master/src/main/java/cn/zhouyafeng/itchat4j/utils/enums/RetCodeEnum.java
  • retcode:
  • NORMAL("0", "普通"),
  • LOGIN_OUT("1102", "退出"),
  • LOGIN_OTHERWHERE("1101", "其它地方登陆"),
  • MOBILE_LOGIN_OUT("1102", "移动端退出"),
  • UNKOWN("9999", "未知") *
  • 自己分析下来
  • selector:
  • 4:有某位联系人更新了个人信息
  • 2:有人发消息了 拉取后,MsgType = 1为文字消息,提取content得到聊天文本
  • 每次拉取,需要更新SyncKey,见WebWxSync函数 *

func WebWxSync

func WebWxSync(loginMap *m.LoginMap) (m.WxRecvMsges, error)

*

  • 微信同步拉取消息,最主要的消息响应逻辑
  • POST:https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxsync?
  • sid=u6j1MoqYJgbI66kO&
  • skey=@crypt_3aaab8d5_1f2b5690081714b78fc9b70ee3e4538c&
  • pass_ticket=M3%252BbNp65pZ53GJwvd7aq%252FQuS5Rd7lctHU0qilHs7Fjw%253D
  • BODY:{
  • "BaseRequest":{"Uin":154158775,"Sid":"u6j1MoqYJgbI66kO","Skey":"@crypt_3aaab8d5_1f2b5690081714b78fc9b70ee3e4538c","DeviceID":"e215003169713295"},
  • "SyncKey":{"Count":8,"List":[{"Key":1,"Val":696275959},{"Key":2,"Val":696276275},{"Key":3,"Val":696276260},{"Key":11,"Val":696275997},{"Key":13,"Val":696160001},{"Key":201,"Val":1504604303},{"Key":1000,"Val":1504603672},{"Key":1001,"Val":1504572152}]},
  • "rr":-1365833882
  • }
  • @param {[type]} loginMap m.LoginMap [description]

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL