带http数据post的Rcurl
我想将以下curl调用转移到Rcurl:带http数据post的Rcurl,r,rcurl,R,Rcurl,我想将以下curl调用转移到Rcurl: curl 'http://myserver.org/stream' -H 'Authorization: Basic XXXXXXXX' -H 'Connection: keep-alive' --data-binary '{"limit": 20}' -H 'Content-Type: application/json;charset=UTF-8' 这是我的R测试之一: library(RCurl) url.opts <- list(ht
curl 'http://myserver.org/stream'
-H 'Authorization: Basic XXXXXXXX' -H 'Connection: keep-alive' --data-binary '{"limit": 20}'
-H 'Content-Type: application/json;charset=UTF-8'
这是我的R测试之一:
library(RCurl)
url.opts <- list(httpheader = list(Authorization ="Basic XXXXXXXX",
Connection = "keep-alive",
"Content-Type" = "application/json;charset=UTF-8"))
getURLContent('http://myserver.org/stream', .opts=url.opts)
库(RCurl)
url.opts非常感谢@hadley
这是我的工作解决方案:
library(httr)
user <- "test"
password <- "test123"
POST(url = 'http://myserver.org/stream',
config = c(authenticate(user, password, "basic"),
add_headers(Connection = "keep-alive"),
accept_json()),
body = "{'username':'test'}")
库(httr)
用户非常感谢@hadley
这是我的工作解决方案:
library(httr)
user <- "test"
password <- "test123"
POST(url = 'http://myserver.org/stream',
config = c(authenticate(user, password, "basic"),
add_headers(Connection = "keep-alive"),
accept_json()),
body = "{'username':'test'}")
库(httr)
用户可以使用getURLContent(…,customrequest='POST',postfields='{“limit”:20}')
或类似的东西。使用httr
:POST('http://myserver.org/stream,c(authenticate(u,p,“basic”),accept_json(),body='{“limit”:20}')
您可以使用getURLContent(…,customrequest='POST',postfields='{“limit”:20}')
或类似的东西。使用httr
:POST('http://myserver.org/stream,c(authenticate(u,p,“basic”),acceptjson(),body='{“limit”:20}')