Go

Go - NewRequest

1
package main
2
​
3
import (
4
"fmt"
5
"strings"
6
"net/http"
7
"io/ioutil"
8
)
9
​
10
func main() {
11
​
12
url := "https://pickyassist.com/app/api/v2/push"
13
​
14
payload := strings.NewReader("{\"token\":\"c2a0b6221c5dd55ceb09ae1f74e46521756d\",\"priority \":0,\"application\":\"2\",\"sleep\":0,\"globalmessage\":\"\",\"globalmedia\":\"\",\"data\":[{\"number\":\"1212\",\"message\":\"Test\"}]}")
15
​
16
req, _ := http.NewRequest("POST", url, payload)
17
​
18
req.Header.Add("content-type", "application/json")
19
​
20
res, _ := http.DefaultClient.Do(req)
21
​
22
defer res.Body.Close()
23
body, _ := ioutil.ReadAll(res.Body)
24
​
25
fmt.Println(res)
26
fmt.Println(string(body))
27
​
28
}
Copied!
Last modified 2yr ago
Copy link