PHP Snippet 1:
# get responses from a survey:
# be sure to update the URL with your survey id number
library(ODataQuery)
s1res <- ODataQuery::retrieve_data(
url = paste0(
"https://api.alchemer.com/v5/survey/yourIdNumberHere/surveyresponse?api_token=",
api_token,
"&api_token_secret=",
apiSecretKey ) )
s1data <- s1res$data # yields a list for each respondent named "survey_data"
df<- tidyr::unnest(s1data$survey_data)
table(df$answer10) # check responses for one question
# remove unnecessary vars using `dplyr`
df2<-df %>% select(starts_with("question") | starts_with("answer")) %>% select(-contains("_id"))
# make column names from the first row of values
q_text<-df2 %>% select(starts_with("question")) %>% slice_head(n=1) %>% as.character()
df3<-df2 %>% select(starts_with("answer"))
colnames(df3)<-str_replace_all(q_text," ","") # assign new col names; check!