Last active
October 4, 2022 18:33
-
-
Save mathzero/f1d1b3b94f6f76019a5861d1bed7d597 to your computer and use it in GitHub Desktop.
Hacky fix for rAltmetrics function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
altmetrics_new <- | |
function(doi = NULL, | |
apikey = NULL, | |
...) { | |
base_url <- "https://api.altmetric.com/v1/" | |
args <- list(key = apikey) | |
request <- | |
httr::GET(paste0(base_url, "doi/",doi)) | |
if(httr::status_code(request) == 404) { | |
stop("No metrics found for object") | |
} else { | |
httr::warn_for_status(request) | |
results <- | |
jsonlite::fromJSON(httr::content(request, as = "text"), flatten = TRUE) | |
results <- rlist::list.flatten(results) | |
class(results) <- "altmetric" | |
results | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment