-
Notifications
You must be signed in to change notification settings - Fork 34
/
wecat_test.go
56 lines (46 loc) · 998 Bytes
/
wecat_test.go
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
package gobot
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"testing"
)
func TestGetUUID(t *testing.T) {
cfg := Load()
fmt.Println(cfg)
wx, err := NewWecat(cfg)
if err != nil {
panic(err)
}
wx.Start()
}
func TestTuling(t *testing.T) {
params := make(map[string]interface{})
params["userid"] = "123123123"
params["key"] = "808811ad0fd34abaa6fe800b44a9556a"
params["info"] = "你好"
data, err := json.Marshal(params)
if err != nil {
fmt.Println(err)
return
}
body := bytes.NewBuffer(data)
req, err := http.NewRequest("POST", "http://www.tuling123.com/openapi/api", body)
if err != nil {
fmt.Println(err)
return
}
req.Header.Set("Content-Type", "application/json;charset=utf-8")
req.Header.Add("Referer", WxReferer)
req.Header.Add("User-agent", WxUserAgent)
resp, err := http.DefaultClient.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer resp.Body.Close()
data, _ = ioutil.ReadAll(resp.Body)
fmt.Println(string(data))
}