-
Notifications
You must be signed in to change notification settings - Fork 1
/
request.go
104 lines (84 loc) · 2.66 KB
/
request.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
"github.com/tidwall/gjson"
)
func SendConfirmLogin(uuid string, values url.Values) bool {
uri := "https://service.mkey.163.com/mpay/api/qrcode/confirm_login"
method := "POST"
requestBodyParams, err := url.ParseQuery("uuid=xxxxx&device_id=amawkzyaasy33xxx-d&token=xxxxx&jf_game_id=ma68&pay_channel=netease&is_remember=0&game_id=aecfrugltuaaaajo-g-ma68&gv=120&gvn=4.3.20&cv=a3.29.0&sv=33&app_type=games&app_mode=2&app_channel=netease&mcount_app_key=EEkEEXLymcNjM42yLY3Bn6AO15aGy4yq&mcount_transaction_id=4514532b-8ec3-11ee-9a36-4b696ee8d233-1")
if err != nil {
panic(err)
}
for k, _ := range requestBodyParams {
if values.Has(k) && requestBodyParams.Get(k) != values.Get(k) {
fmt.Println("replace", k, requestBodyParams.Get(k), values.Get(k))
requestBodyParams.Set(k, values.Get(k))
}
}
requestBodyParams.Set("uuid", uuid)
payload := strings.NewReader(requestBodyParams.Encode())
client := &http.Client{}
req, err := http.NewRequest(method, uri, payload)
if err != nil {
panic(err)
}
req.Header.Add("Accept-Charset", "UTF-8")
req.Header.Add("Content-type", "application/x-www-form-urlencoded")
res, err := client.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println("POST", uri)
fmt.Println(requestBodyParams.Encode())
fmt.Println(string(body))
if res.StatusCode == 200 && gjson.Get(string(body), "code").Int() == 0 {
return true
} else {
return false
}
}
func ScanRequestSend(uuid string, values url.Values) bool {
uri := "https://service.mkey.163.com/mpay/api/qrcode/scan?uuid=xxxxx&cv=a3.29.0&game_id=aecfrugltuaaaajo-g-ma68&gv=120&gvn=4.3.20&sv=33&app_type=games&app_mode=2&app_channel=netease&mcount_app_key=EEkEEXLymcNjM42yLY3Bn6AO15aGy4yq&mcount_transaction_id=4514532b-8ec3-11ee-9a36-4b696ee8d233-1"
reqUrl, err := url.Parse(uri)
if err != nil {
panic(err)
}
queryParams := reqUrl.Query()
for k, _ := range queryParams {
if values.Has(k) && queryParams.Get(k) != values.Get(k) {
fmt.Println("replace", k, queryParams.Get(k), values.Get(k))
queryParams.Set(k, values.Get(k))
}
}
queryParams.Set("uuid", uuid)
reqUrl.RawQuery = queryParams.Encode()
method := "GET"
client := &http.Client{}
req, err := http.NewRequest(method, reqUrl.String(), nil)
if err != nil {
panic(err)
}
req.Header.Add("Accept-Charset", "UTF-8")
res, err := client.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
panic(err)
}
fmt.Println("GET", reqUrl.String())
fmt.Println(string(body))
return true
}