Reputation: 709
I used to use RCurl, to grab the data that needs login. Now I have to grab the data using api key (as well as userid,password) and it needs a basic authentication (Radian6 api : http://socialcloud.radian6.com/docs/read/Getting_Started)
If it doesn't need an authentication, the code will be something like..
getURL("https:// address", userpwd="id:pswd", httpauth = 1L)
but I have no idea how to plug in api key for authentication. So far I was able to find examples written in python or Java but haven't found R example yet. Can anyone point me to the right direction? I'm wondering how I can use RCurl for basic authentication and how I can use a token to grab the data. (fyi, this is how python works :Urllib2 authentication with API key)
Any advice will be very appreciated!
Upvotes: 1
Views: 7762
Reputation: 103928
You might find it a little easier to use httr. The code would look something like this:
library(httr)
req <- GET("https://address.com/authenticate",
authenticate("user", "pass", type = "basic"),
add_headers(auth_appkey = api_key))
stop_for_status(req)
content(req)
# Then extract token etc
Upvotes: 8