forked from NdoleStudio/httpsms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
42 lines (36 loc) · 852 Bytes
/
main.go
File metadata and controls
42 lines (36 loc) · 852 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
37
38
39
40
41
42
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/joho/godotenv"
"github.com/carlmjohnson/requests"
"github.com/palantir/stacktrace"
)
func main() {
err := godotenv.Load("../../.env")
if err != nil {
log.Fatal("Error loading .env file")
}
for i := 0; i < 20; i++ {
var responsePayload string
err = requests.
URL("/v1/messages/send").
Host("api.httpsms.com").
// Host("localhost:8000").
// Scheme("http").
Header("x-api-key", os.Getenv("API_KEY")).
BodyJSON(&map[string]string{
"content": fmt.Sprintf("testing http api sample: [%d]", i),
"from": "+37259139660",
"to": "+37253517181",
}).
ToString(&responsePayload).
Fetch(context.Background())
if err != nil {
log.Fatal(stacktrace.Propagate(err, "cannot create json payload"))
}
log.Println(responsePayload)
}
}