=== modified file 'src/docbkx/en/dhis2_r.xml' --- src/docbkx/en/dhis2_r.xml 2012-05-23 14:54:01 +0000 +++ src/docbkx/en/dhis2_r.xml 2012-06-01 06:01:20 +0000 @@ -446,9 +446,18 @@ require(RCurl) require(XML) #Just a URL with some data -url<-"https://apps.dhis2.org/dev/api/reportTables/data.csv?de=fbfJHSPpUQD&de=cYeuwXTCPkU&in=Uvn6LCg7dVU&ou=O6uvpzGd5pu&last12Months=true" + +url<-"https://apps.dhis2.org/dev/api/reportTables/data.csv? +de=fbfJHSPpUQD +&de=cYeuwXTCPkU +&in=Uvn6LCg7dVU +&ou=O6uvpzGd5pu +&last12Months=true" #Lets get the response and we do not need the headers -response<-getURL(url,userpwd="admin:district",httpauth = 1L, header=FALSE) +#This site has some issues with its SSL certificate +#so lets not verify it. +response<-getURL(url,userpwd="admin:district" +,httpauth = 1L, header=FALSE,ssl.verifypeer = FALSE) #Unquote the data data<-noquote(response) #here is the data. @@ -458,10 +467,12 @@ Here, we have shown how to get some aggregate data from the DHIS2 demo database using the DHIS2's Web API. In the next code example, we will retrieve some metadata, namely a list of data elements and their unique identifiers. #Get the list of data elements. Turn off paging and links +#This site has some issues with its SSL certificate +#so lets not verify it. url<-"https://apps.dhis2.org/dev/api/dataElements.xml? paging=false&links=false" response<-getURL(url,userpwd="admin:district", -httpauth = 1L, header=FALSE) +httpauth = 1L, header=FALSE,ssl.verifypeer = FALSE) #We ned to parse the result bri<-xmlParse(response) #And get the root @@ -474,9 +485,10 @@ #but we need to be careful for missing attribute values foo<-cbind(de_names,de_id) #Recast this as a data frame -data_elements<-as.data.frame(foo,stringsAsFactors=FALSE,row.names=1:nrow(foo)) +data_elements<-as.data.frame(foo, +stringsAsFactors=FALSE,row.names=1:nrow(foo)) head(data_elements) - Note that the values which we are interested in are stored as XML attributes and were parsed into two seperate matrices and then combined together into a single data frame. + Note that the values which we are interested in are stored as XML attributes and were parsed into two separate matrices and then combined together into a single data frame.