api_key = get_api_key(NULL, error = FALSE)
if (!is.null(api_key)){
x = object_retrieval("S1053811915002700", identifier = "pii")
if (require(xml2) & require(httr)){
library(httr)
refs = httr::content(x$get_statement, "text")
refs = read_xml(refs)
refs = xml_nodes(refs, "choice")
texts = xml_text(refs)
types = xml_attr(refs, "type")
refs = xml_attr(refs, "ref")
df = data.frame(ref = refs, type = types, text = texts,
stringsAsFactors = FALSE)
df = df[ grepl("image/jpeg", df$text),,drop = FALSE ]
df = df[ df$type %in% "IMAGE-HIGH-RES",,drop = FALSE ]
r = GET(df$text[1],
query = list(
"apiKey" = api_key))
img = content(r)
dims = dim(img)[1:2]
mdim = max(dims)
plot(c(0, ncol(img)), c(0, nrow(img)), type='n')
rasterImage(img, 1, 1, ncol(img), nrow(img))
}
obj = object_retrieval('S1053811915002700', "pii")
}
Run the code above in your browser using DataLab