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)
}

4.17
6
Daschin 90 points

                                    library(&quot;knitr&quot;)
library(urlshorteneR)

4.17 (6 Votes)
0
4
2
Lee Sexsmith 135 points

                                    if (interactive()) {
bitly_update_user(name = &quot;John Malc&quot;, showRequestURL = TRUE)
}

4 (2 Votes)
0
4.5
10
Kristi 100 points

                                    if (interactive()) {

bitly_retrieve_group(ui$default_group_guid)
bitly_retrieve_groups()
}

4.5 (10 Votes)
0
4.25
4
Subramanian 100 points

                                    if (interactive()) {
bitly_app_details()
}

4.25 (4 Votes)
0
5
2

                                    ## In order to use bitly functions, you first need to authenticate. 
##                         For that execute 'bitly_auth()' in R console.

5 (2 Votes)
0
0
0
Zbw 80 points

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

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

  ui &lt;- bitly_user_info(showRequestURL = TRUE)
  is_bitly_user_premium_holder()
}

0
0
Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source