代码拉取完成,页面将自动刷新
同步操作将从 MAKOTO/openwechat 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package openwechat
import (
"context"
"net/http"
"net/url"
"strconv"
"time"
)
type Mode interface {
BuildGetLoginUUIDRequest(ctx context.Context) (*http.Request, error)
BuildGetLoginInfoRequest(ctx context.Context, path string) (*http.Request, error)
BuildPushLoginRequest(ctx context.Context, host string, uin int64) (*http.Request, error)
}
var (
// normal 网页版模式
normal Mode = normalMode{}
// desktop 桌面模式,uos electron套壳
desktop Mode = desktopMode{}
)
type normalMode struct{}
func (n normalMode) BuildGetLoginUUIDRequest(ctx context.Context) (*http.Request, error) {
path, err := url.Parse(jslogin)
if err != nil {
return nil, err
}
params := url.Values{}
redirectUrl, err := url.Parse(webwxnewloginpage)
if err != nil {
return nil, err
}
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()
return http.NewRequestWithContext(ctx, http.MethodGet, path.String(), nil)
}
func (n normalMode) BuildGetLoginInfoRequest(ctx context.Context, path string) (*http.Request, error) {
return http.NewRequestWithContext(ctx, http.MethodGet, path, nil)
}
func (n normalMode) PushLogin(ctx context.Context, client *Client, uin int64) (*http.Response, error) {
path, err := url.Parse(client.Domain.BaseHost() + webwxpushloginurl)
if err != nil {
return nil, err
}
params := url.Values{}
params.Add("uin", strconv.FormatInt(uin, 10))
path.RawQuery = params.Encode()
req, err := http.NewRequestWithContext(ctx, http.MethodGet, path.String(), nil)
if err != nil {
return nil, err
}
return client.Do(req)
}
func (n normalMode) BuildPushLoginRequest(ctx context.Context, host string, uin int64) (*http.Request, error) {
path, err := url.Parse(host + webwxpushloginurl)
if err != nil {
return nil, err
}
params := url.Values{}
params.Add("uin", strconv.FormatInt(uin, 10))
path.RawQuery = params.Encode()
return http.NewRequestWithContext(ctx, http.MethodGet, path.String(), nil)
}
type desktopMode struct{}
func (n desktopMode) BuildGetLoginUUIDRequest(ctx context.Context) (*http.Request, error) {
path, err := url.Parse(jslogin)
if err != nil {
return nil, err
}
params := url.Values{}
redirectUrl, err := url.Parse(webwxnewloginpage)
if err != nil {
return nil, err
}
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()
return http.NewRequestWithContext(ctx, http.MethodGet, path.String(), nil)
}
func (n desktopMode) BuildGetLoginInfoRequest(ctx context.Context, path string) (*http.Request, error) {
req, err := http.NewRequestWithContext(ctx, http.MethodGet, path, nil)
if err != nil {
return nil, err
}
req.Header.Add("client-version", uosPatchClientVersion)
req.Header.Add("extspam", uosPatchExtspam)
return req, nil
}
func (n desktopMode) BuildPushLoginRequest(ctx context.Context, host string, uin int64) (*http.Request, error) {
path, err := url.Parse(host + webwxpushloginurl)
if err != nil {
return nil, err
}
params := url.Values{}
params.Add("uin", strconv.FormatInt(uin, 10))
params.Add("mod", "desktop")
path.RawQuery = params.Encode()
return http.NewRequestWithContext(ctx, http.MethodGet, path.String(), nil)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。