-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetPagePerformance.go
43 lines (36 loc) · 1.06 KB
/
GetPagePerformance.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
// Get API key at www.interzoid.com/register
package main
import (
"encoding/json"
"fmt"
"net/http"
)
type Payload struct {
Origin string
Seconds string
PageResponseStatus string
Contents string
Code string
Credits int
}
func main() {
// Create the struct variable to store the decoded JSON response
thePayload := Payload{}
// Call the API
// Can error check here too replacing underscore with 'err'
response, _ := http.Get("https://api.interzoid.com/globalpageload?license=
YOURAPILICENSEKEY&origin=singapore&url=www.ebay.com")
if response.StatusCode != 200 {
// Report any HTTP Errors
fmt.Println("Error: ", response.Status)
} else {
// Decode the JSON and print a comma-delimited response,
// one of many ways to format the response
_ = json.NewDecoder(response.Body).Decode(&thePayload)
fmt.Println(
thePayload.Origin + "," +
thePayload.Seconds + "," +
thePayload.PageResponseStatus + "," +
thePayload.Contents)
}
}