I'm attempting to use R to shorten a batch of URLs quickly. The google API documentation provides the solution below using curl
curl https://www.googleapis.com/urlshortener/v1/url \
-H 'Content-Type: application/json' \
-d '{"longUrl": "http://www.google.com/"}'
I tried converting it to R using R, but I keep getting "Error: Bad Request". Here is what I'm working with.
library(RCurl)
library(RJSONIO)
postForm( "https://www.googleapis.com/urlshortener/v1/url" ,
.params= c(data = '{"longUrl":"www.google.com"}'),
.opts = list( httpheader = "Content-Type: application/json",
ssl.verifypeer = FALSE))