The readHFDweb function and associated utility functions were no longer working because (I think) the HFD website moved from http to https.
These problems are fixed by using the httr library instead of Rcurl. This also simplifies the authentication.
I did not make any changes to the way HMDHFDplus manages HFD credentials (in contrast to previous discussion), as I think it is probably easier to manage this inside a script after all.
A simple test
library(HMDHFDplus)
user <- Sys.getenv("HFD_user")
pass <- Sys.getenv("HFD_pass")
births <- readHFDweb("GBRTENW", item="birthsVV",
user=user,password=pass)
expos <- readHFDweb("GBRTENW", item="exposRR",
user=user,password=pass)
countries <- getHFDcountries()
country <- sample(countries,1)
# the itemavail function only works if logged in (e.g. after readHFDweb has been called once)
items <- getHFDitemavail(country)
item <- sample(items,1)
df <- readHFDweb(country, item, user=user, password=pass)
print(country)
print(item)
class(df)
head(df)
# asks to choose an item when user-specified item doesn't exist.
df <- readHFDweb(country, "blibble", user=user, password=pass)
The
readHFDweb
function and associated utility functions were no longer working because (I think) the HFD website moved fromhttp
tohttps
. These problems are fixed by using thehttr
library instead ofRcurl
. This also simplifies the authentication.I did not make any changes to the way HMDHFDplus manages HFD credentials (in contrast to previous discussion), as I think it is probably easier to manage this inside a script after all.
A simple test