Repository navigation
Expand file tree
/
Copy pathcompareFin.R
More file actions
53 lines (46 loc) · 1.43 KB
/
Copy pathcompareFin.R
File metadata and controls
53 lines (46 loc) · 1.43 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
library(jsonlite)
library(httr)
getLLS <- function(x) {
postcode = x
postcode = gsub(" ", "", postcode)
debug=TRUE
llsVal = ''
#uri <- paste("http://mybbc-locator-locservices-gss.api.bbci.co.uk/?limit=1&postcode=", postcode, sep='')
uri <- paste("https://mybbc-locator-locservices-gss.api.bbci.co.uk/?op=intersect&limit=1&postcode=", postcode, sep='')
resp <- GET(uri)
if(debug) print("call done to LLS")
if(debug) print(uri)
if(http_status(resp) != "Success"){
if(debug) print(http_status(resp))
# stop("API did not return valid status")
llsVal="error"
}else{
data <- fromJSON(content(resp, "text"))
if(debug) print(data$response$details$externalId)
llsVal = data$response$details$externalId
}
#Sys.sleep(0.2)
x = llsVal
}
getForge <- function(x) {
postcode = x
postcode = gsub(" ", "", postcode)
debug=TRUE
forgeVal = ''
uri <- paste("http://open.stage.bbc.co.uk/locator/locations/", postcode, sep='')
uri <- paste(uri, "/details/gss-seat?op=intersect", sep='')
resp <- GET(uri)
if(debug) print("call done to Forge")
if(debug) print(uri)
if(http_status(resp) != "Success"){
if(debug) print(http_status(resp))
# stop("API did not return valid status")
forgeVal="error"
}else{
data <- fromJSON(content(resp, "text"))
if(debug) print(data$response$details$externalId)
forgeVal = data$response$details$externalId
}
Sys.sleep(0.2)
x = forgeVal
}