|
@@ -0,0 +1,51 @@
|
|
1
|
+package lib
|
|
2
|
+
|
|
3
|
+import (
|
|
4
|
+ "encoding/json"
|
|
5
|
+ "io/ioutil"
|
|
6
|
+ "log"
|
|
7
|
+ "net/http"
|
|
8
|
+)
|
|
9
|
+
|
|
10
|
+func curl(auth string) *UserData {
|
|
11
|
+
|
|
12
|
+ req, err := http.NewRequest("POST", "http://208.97.141.22/api/sign/user_data", nil)
|
|
13
|
+
|
|
14
|
+ if err != nil {
|
|
15
|
+ return nil
|
|
16
|
+ }
|
|
17
|
+
|
|
18
|
+ req.Header.Set("Auth", auth)
|
|
19
|
+
|
|
20
|
+ resp, err := http.DefaultClient.Do(req)
|
|
21
|
+
|
|
22
|
+ if err != nil {
|
|
23
|
+ log.Print(err)
|
|
24
|
+ return nil
|
|
25
|
+ }
|
|
26
|
+
|
|
27
|
+ defer resp.Body.Close()
|
|
28
|
+
|
|
29
|
+ body, _ := ioutil.ReadAll(resp.Body)
|
|
30
|
+
|
|
31
|
+ // debug only
|
|
32
|
+ //s := string(body[:])
|
|
33
|
+ //fmt.Println(s)
|
|
34
|
+
|
|
35
|
+ var userData UserData
|
|
36
|
+
|
|
37
|
+ err = json.Unmarshal(body, &userData)
|
|
38
|
+
|
|
39
|
+ //fmt.Printf("%+v\n", userData)
|
|
40
|
+
|
|
41
|
+ if err != nil {
|
|
42
|
+ log.Print(err)
|
|
43
|
+ return nil
|
|
44
|
+ }
|
|
45
|
+
|
|
46
|
+ if len(userData.Errors) > 0 {
|
|
47
|
+ return nil
|
|
48
|
+ }
|
|
49
|
+
|
|
50
|
+ return &userData
|
|
51
|
+}
|