2013-10-04 41 views
2
用的getURL的RESTful API

我想翻譯下面的HTTP GET命令RCurl工作:設置查詢參數在RCurl

curl -G https://api.example.com/resource \ 
-d "param=value" \ 
-d "param=value" \ 
-u 'user:password' 

這裏是RCurl利用的getURL我嘗試:

getURL("https://api.example.com/resource", 
userpwd ="username:password",param="value",param="value") 

第一個代碼塊在我的命令行終端中工作正常,我沒有使用getURL的麻煩,直到我嘗試設置參數;我收到警告信息,說明這些參數是「無法識別的CURL選項」。有任何想法嗎?

+0

張貼了我的RCurl嘗試。 – user2844910

回答

3

參數...的任何內容都被解釋爲捲曲選項。您需要將參數作爲httpheader參數中的列表。 See documentation

試着這麼做:

getURL("https://api.example.com/resource", 
     userpwd ="username:password", 
     httpheader=list(param1="value",param2="value"))