1
我试图用R来快速缩短一批网址。在谷歌API文档提供了解决方案下面使用curl谷歌API - 与R的URL缩短器
curl https://www.googleapis.com/urlshortener/v1/url \
-H 'Content-Type: application/json' \
-d '{"longUrl": "http://www.google.com/"}'
我试过,使用R将其转换为R,但我不断收到“错误:错误的请求”。这是我正在与之合作。
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))
跳过斜杠在您的JSON有更多的运气解析输出。 – Thomas
它适合你吗?如果是这样,你可以发布代码,因为它不断给我同样的错误。 – user1637000