【发布时间】:2014-06-07 13:59:36
【问题描述】:
我正在尝试使用 R 快速缩短一批 URL。 google API 文档使用 curl 提供了以下解决方案
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 中的斜杠。
-
它对你有用吗?如果是这样,您可以发布代码,因为它一直给我同样的错误。