-
Notifications
You must be signed in to change notification settings - Fork 1
/
internetbs.go
53 lines (45 loc) · 1.21 KB
/
internetbs.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
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
)
func updateDns(apiKey, password, fullrecordname, recordtype, newvalue string) (transactid, status, message string) {
// Test Api
Url := "https://api.internet.bs/Domain/DnsRecord/Update"
param := url.Values{}
param.Add("apiKey", apiKey)
param.Add("password", password)
param.Add("fullrecordname", fullrecordname)
param.Add("type", recordtype)
param.Add("newvalue", newvalue)
param.Add("ResponseFormat", "JSON")
req, err := http.NewRequest("POST", Url, strings.NewReader(param.Encode()))
if err != nil {
fmt.Println(err)
}
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
resp, err := http.DefaultClient.Do(req)
if err != nil {
fmt.Println(err)
}
defer resp.Body.Close()
jsonblob, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println(err)
}
transactid, status, message = decodeResponse(jsonblob)
return
}
func decodeResponse(jsonblob []byte) (transactid, status, message string) {
var response Response
json.Unmarshal(jsonblob, &response)
transactid = response.Transactid
status = response.Status
message = response.Message
return
}