A small library for generating short URLs in R.
The longurl package will expand URLs from a range of URL shortening services. There is a surprisingly large number of these services (check out the list). I tried this package and it does a great job of expanding shortened URLs. It does not provide a shortening service though or access to analytics.
You can install the library directly from the github repository.
library(devtools)
install_github("DataWookie/urlshorteneR")
Load the library.
library(urlshorteneR)
Authenticate for goo.gl.
key = "863558629146-3bh2qh1j4c976mf5dtm6n73gi85esn2h.apps.googleusercontent.com"
secret = "BmLO7fMzZWwexWDp4x0sNh_c"
shortener_authenticate(key, secret)
Shorten, expand and query analytics.
shorten.google("http://www.google.com")
expand.google("http://goo.gl/3WwfIY")
analytics.google("http://goo.gl/3WwfIY")
Authenticate for bitly.
key = "692987373a97579f9faca10e7c2ea15d6c56fd97"
secret = "752c5fe36d8596fcc73421090260ebe0d7cbc1a9"
shortener_authenticate(key, secret, "bitly")
Shorten, expand and query analytics.
shorten.bitly("http://www.google.com")
expand.bitly("http://bit.ly/1Qho4Y5")
analytics.bitly("http://bit.ly/1Qho4Y5")
Read the high level overview of Google's URL shortener API, more details can be found in the API documentation.
The first thing that you need to do is set up a project in the Google Developers' Console. The process can be broken down as follows:
Further information on OAuth 2.0 authentication at Google can be found here and here.
Create an account on bitly. Login and then register a bitly application. Retrieve the Client ID and Client Secret for the application. Check out the information on bitly authentication. The details of bitly API are worth a read, but not essential because this functionality is implemented by urlshorteneR.
Set this to http://localhost:1410.