代码拉取完成,页面将自动刷新
package openwechat
import (
"net/http"
"net/url"
"strconv"
"time"
)
type Mode interface {
GetLoginUUID(client *Client) (*http.Response, error)
GetLoginInfo(client *Client, path string) (*http.Response, error)
PushLogin(client *Client, uin int64) (*http.Response, error)
}
var (
// normal 网页版模式
normal Mode = normalMode{}
// desktop 桌面模式,uos electron套壳
desktop Mode = desktopMode{}
)
type normalMode struct{}
func (n normalMode) PushLogin(client *Client, uin int64) (*http.Response, error) {
path, _ := url.Parse(client.Domain.BaseHost() + webwxpushloginurl)
params := url.Values{}
params.Add("uin", strconv.FormatInt(uin, 10))
path.RawQuery = params.Encode()
req, _ := http.NewRequest(http.MethodGet, path.String(), nil)
return client.Do(req)
}
func (n normalMode) GetLoginUUID(client *Client) (*http.Response, error) {
path, _ := url.Parse(jslogin)
params := url.Values{}
redirectUrl, _ := url.Parse(webwxnewloginpage)
params.Add("redirect_uri", redirectUrl.String())
params.Add("appid", appId)
params.Add("fun", "new")
params.Add("lang", "zh_CN")
params.Add("_", strconv.FormatInt(time.Now().UnixNano()/1e6, 10))
path.RawQuery = params.Encode()
req, _ := http.NewRequest(http.MethodGet, path.String(), nil)
return client.Do(req)
}
func (n normalMode) GetLoginInfo(client *Client, path string) (*http.Response, error) {
req, _ := http.NewRequest(http.MethodGet, path, nil)
return client.Do(req)
}
type desktopMode struct{}
func (n desktopMode) GetLoginUUID(client *Client) (*http.Response, error) {
path, _ := url.Parse(jslogin)
params := url.Values{}
redirectUrl, _ := url.Parse(webwxnewloginpage)
p := url.Values{"mod": {"desktop"}}
redirectUrl.RawQuery = p.Encode()
params.Add("redirect_uri", redirectUrl.String())
params.Add("appid", appId)
params.Add("fun", "new")
params.Add("lang", "zh_CN")
params.Add("_", strconv.FormatInt(time.Now().UnixNano()/1e6, 10))
path.RawQuery = params.Encode()
req, _ := http.NewRequest(http.MethodGet, path.String(), nil)
return client.Do(req)
}
func (n desktopMode) GetLoginInfo(client *Client, path string) (*http.Response, error) {
req, _ := http.NewRequest(http.MethodGet, path, nil)
req.Header.Add("client-version", uosPatchClientVersion)
req.Header.Add("extspam", uosPatchExtspam)
return client.Do(req)
}
func (n desktopMode) PushLogin(client *Client, uin int64) (*http.Response, error) {
path, _ := url.Parse(client.Domain.BaseHost() + webwxpushloginurl)
params := url.Values{}
params.Add("uin", strconv.FormatInt(uin, 10))
params.Add("mod", "desktop")
path.RawQuery = params.Encode()
req, _ := http.NewRequest(http.MethodGet, path.String(), nil)
return client.Do(req)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。