MCPcopy
hub / github.com/eatmoreapple/openwechat / GetLoginUUID

Method GetLoginUUID

caller.go:33–51  ·  view source on GitHub ↗

GetLoginUUID 获取登录的uuid

(ctx context.Context)

Source from the content-addressed store, hash-verified

31
32// GetLoginUUID 获取登录的uuid
33func (c *Caller) GetLoginUUID(ctx context.Context) (string, error) {
34 resp, err := c.Client.GetLoginUUID(ctx)
35 if err != nil {
36 return "", err
37 }
38 defer func() { _ = resp.Body.Close() }()
39
40 var buffer bytes.Buffer
41 if _, err = buffer.ReadFrom(resp.Body); err != nil {
42 return "", err
43 }
44 // 正则匹配uuid字符串
45 results := uuidRegexp.FindSubmatch(buffer.Bytes())
46 if len(results) != 2 {
47 // 如果没有匹配到,可能微信的接口做了修改,或者当前机器的ip被加入了黑名单
48 return "", errors.New("uuid does not match")
49 }
50 return string(results[1]), nil
51}
52
53// CheckLogin 检查是否登录成功
54func (c *Caller) CheckLogin(ctx context.Context, uuid, tip string) (CheckLoginResponse, error) {

Callers 2

LoginMethod · 0.45
TestGetUUIDFunction · 0.45

Calls 1

CloseMethod · 0.80

Tested by 1

TestGetUUIDFunction · 0.36