Answers for "unshorten url in R"

0

unshorten url in R

decode_short_url <- function(url, ...) {
  # PACKAGES #
  require(RCurl)
 
  # LOCAL FUNCTIONS #
  decode <- function(u) {
    Sys.sleep(0.5)
    x <- try( getURL(u, header = TRUE, nobody = TRUE, followlocation = FALSE, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")) )
    if(inherits(x, 'try-error') | length(grep(".*Location: (\\S+).*", x))<1) {
      return(u)
    } else {
      return(gsub('.*Location: (\\S+).*', '\\1', x))
    }
  }
 
  # MAIN #
  gc()
  # return decoded URLs
  urls <- c(url, ...)
  l <- vector(mode = "list", length = length(urls))
  l <- lapply(urls, decode)
  names(l) <- urls
  return(l)
}
Posted by: Guest on May-24-2020
0

unshorten url in R

## In order to use bitly functions, you first need to authenticate. 
##                         For that execute 'bitly_auth()' in R console.
Posted by: Guest on May-26-2020
0

unshorten url in R

if (interactive()) {

bitly_retrieve_group(ui$default_group_guid)
bitly_retrieve_groups()
}
Posted by: Guest on May-26-2020
0

unshorten url in R

library("knitr")
library(urlshorteneR)
Posted by: Guest on May-26-2020
0

unshorten url in R

if (interactive()) {
bitly_update_user(name = "John Malc", showRequestURL = TRUE)
}
Posted by: Guest on May-26-2020
0

unshorten url in R

if (interactive()) {
bitly_app_details()
}
Posted by: Guest on May-26-2020
0

unshorten url in R

if(interactive()) {
  opts_knit$set(root.dir = "~/Documents/Documents2/R-package-urlshortener")
  bitly_token <- readRDS("tests/bitly_local_token.rds")

# You can register a new pair of keys yourself - but you can also use mine - an option which is also by default
# bitly_token <- bitly_auth(key = "be03aead58f23bc1aee6e1d7b7a1d99d62f0ede8", secret = "f9c6a3b18968e991e35f466e90c7d883cc176073")
# bitly_token <- bitly_auth()

  ui <- bitly_user_info(showRequestURL = TRUE)
  is_bitly_user_premium_holder()
}
Posted by: Guest on May-26-2020

Browse Popular Code Answers by Language