Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带http数据post的Rcurl_R_Rcurl - Fatal编程技术网

带http数据post的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调用转移到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(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}')