1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package wx
import (
"encoding/base64"
"encoding/json"
"fmt"
"github.com/medivhzhan/weapp/v2"
"io/ioutil"
"time"
)
func GetUnlimited(token string, scene string, page string, width int, colorR string, colorG string, colorB string) (string, error) {
getter := weapp.UnlimitedQRCode{
Scene: scene,
Page: page,
Width: width,
AutoColor: true,
LineColor: weapp.Color{colorR, colorG, colorB},
IsHyaline: true,
}
fmt.Println(token)
reply, _ := json.Marshal(getter)
fmt.Println(string(reply))
resp, res, err := getter.Get(token)
if err != nil {
// 处理一般错误信息
return "", err
}
if err := res.GetResponseError(); err != nil {
// 处理微信返回错误信息
return "", err
}
defer resp.Body.Close()
content, err := ioutil.ReadAll(resp.Body)
sEnc := base64.StdEncoding.EncodeToString(content)
// 处理图片内容
return sEnc, nil
}
func GetScheme(token string, path string, query string) string {
schemedInfo := weapp.SchemedInfo{
Path: path,
Query: query,
}
getter := weapp.URLScheme{
SchemedInfo: &schemedInfo,
ExpireTime: time.Now().AddDate(0, 1, 0).Unix(),
IsExpire: true,
}
res, err := getter.Generate(token)
if err != nil {
// 处理一般错误信息
return err.Error()
}
if err := res.GetResponseError(); err != nil {
// 处理微信返回错误信息
return err.Error()
}
//defer resp.Body.Close()
//content, err := ioutil.ReadAll(resp.Body)
//sEnc := base64.StdEncoding.EncodeToString(content)
// 处理图片内容
return res.Openlink
}