-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAMPRestAPI.R
More file actions
80 lines (57 loc) · 1.66 KB
/
AMPRestAPI.R
File metadata and controls
80 lines (57 loc) · 1.66 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#-----------| AMP REST API |-----------#
# DEFINITION
# utilize deeplink.com API
# AUTHORS
# Mechelle Warneke <- c(
# Email = "mechellewarneke@gmail.com",
# Website = "mechellewarneke.com",
# BVACCEL = c(
# Email = "mechelle@bvaccel.com",
# Position = "XO Strategist | Technical Web Analyst"
# )
# )
# Hana Omori <- c(
# Email = "hana.beth.omori@gmail.com",
# Website = "hanaomori.com",
# SEER = c(
# Email = "hanao@seerinteractive.com",
# Position = "Technical SEO Account Manager"
# )
# )
# AMP REST API R: v1.1
# COPYRIGHT 2017
# LICENSES: MIT ( https://opensource.org/licenses/MIT )
#------------| Install Dependencies |--------------#
listPackages <- c(
"httr",
"curl",
"jsonlite")
data.frame(
Package = listPackages,
Loaded = sapply(listPackages, require,
character.only = TRUE))
#-----------| AMP API URL |-----------#
url <- paste0(
# -- AMP API URL -- #
"https://searchconsole.googleapis.com/v1/urlTestingTools/mobileFriendlyTest:run?", # modify as needed
# -- AMP API PARAMETERS -- #
# API KEY
"key=", # Do not modify
"AIzaSyCJabY9hmz-ew2O1kihQLyrJrpEanNN5Qs" # modify
)
#-----------| Headers |-----------#
headers <- list(
# -- URL TO RUN TEST ON -- #
url = "https://www.amerigas.com" # modify
)
#-----------| Run POST |-----------#
x <- POST(url,
body = headers,
encode = "json")
#-----------| Get Data |-----------#
data <- fromJSON(rawToChar(x$content))
#-----------| Results |-----------#
status <- data$testStatus$status
mobileFriendliness <- data$mobileFriendliness
resourceIssues <- data$resourceIssues
#-----------| FOOTER | Sandbox |-----------#