1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# Do the hard work of formatting the parameters and issuing the query
epi_query <- function(args) {
qs <- paste(sprintf("%s=%s", names(args), args), collapse="&")
httr::POST(
"https://www.epi.org/wp-admin/admin-ajax.php",
httr::add_headers(`X-Requested-With`="XMLHttpRequest"),
encode="form",
body=list(action="epi_getdata", queryString = qs)) -> res
httr::stop_for_status(res)
jsonlite::fromJSON(httr::content(res, as="text"), flatten=TRUE)
}