-
Notifications
You must be signed in to change notification settings - Fork 1
/
verify.go
66 lines (57 loc) · 2.13 KB
/
verify.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
package mobtexting_sms
import (
"net/http"
"io/ioutil"
)
func VerifySend(to string, access_token string) string{
var api_endpoint = "https://portal.mobtexting.com/api/v2/"
var url = api_endpoint + "verify?to=" + to
req, err := http.NewRequest("POST", url, nil)
req.Header.Set("Authorization", "Bearer " + access_token)
req.Header.Set("Accept", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return "request error!"
}
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {
bodyBytes, err2 := ioutil.ReadAll(resp.Body)
bodyString := string(bodyBytes)
if(err2 != nil){
return "request error!!"
}else{
return bodyString
}
}
return ""
}
func VerifyCheck(id string, token string, access_token string) string{
return doGet("verify/check/" + id + "/" + token, access_token)
}
func VerifyCancel(id string, access_token string) string{
return doGet("verify/cancel/" + id, access_token)
}
func doGet(url string, access_token string) string{
var api_endpoint = "https://portal.mobtexting.com/api/v2/"
url = api_endpoint + url
req, err := http.NewRequest("GET", url, nil)
req.Header.Set("Authorization", "Bearer " + access_token)
req.Header.Set("Accept", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return "request error!"
}
defer resp.Body.Close()
if resp.StatusCode == http.StatusOK {
bodyBytes, err2 := ioutil.ReadAll(resp.Body)
bodyString := string(bodyBytes)
if(err2 != nil){
return "request error!!"
}else{
return bodyString
}
}
return ""
}