-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathgolang-calls.go
More file actions
36 lines (26 loc) · 865 Bytes
/
golang-calls.go
File metadata and controls
36 lines (26 loc) · 865 Bytes
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
package main
import "net/url"
import "io/ioutil"
import "fmt"
import "net/http"
import "bytes"
import "strconv"
func main() {
fmt.Println("I will now try to make a call!")
data := url.Values{
"from": {"+46709751949"},
"to": {"+46700000000"},
"voice_start":{'{"connect":"+461890510"}'}}
req, err := http.NewRequest("POST", "https://api.46elks.com/a1/Calls", bytes.NewBufferString(data.Encode()))
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
req.Header.Add("Content-Length", strconv.Itoa(len(data.Encode())))
req.SetBasicAuth("<API Username>", "<API Password>")
client := &http.Client{}
resp, err := client.Do(req)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Oh dear!!!")
}
fmt.Println(string(body))
}