#' @title Accepts a tiny.cc short url and returns the total visits
#' @description tbd.
#' @details tbd.
#' @param shortURL character, the short url to get visit totals.
#' @return A list, representing the response from the tiny.cc API.
#' @author Philipp Ottolinger
#' @seealso \code{<https://tiny.cc/api-docs>}
#' @importFrom httr modify_url
#' @importFrom httr GET
#' @importFrom httr stop_for_status
#' @importFrom httr content
#' @importFrom jsonlite fromJSON
#' @examples
#'
#' @export
total_visits <- function(shortURL) {
request <- httr::modify_url(url = "http://tiny.cc/",
query = list(
"c" = "rest_api",
"m" = "total_visits",
"version" = "2.0.3",
"format" = "json",
"shortUrl" = shortURL,
"login" = Sys.getenv("TINYCC_LOGIN"),
"apiKey" = Sys.getenv("TINYCC_API_KEY")
)
)
result <- httr::GET(request)
httr::stop_for_status(result)
content <- jsonlite::fromJSON(httr::content(result, as = "text"))
return(content)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.