Finally got the http grab function work again

This commit is contained in:
Blue Fox 2023-06-11 15:39:28 +02:00
parent 1c455ac177
commit 83ab933fdf

View File

@ -34,19 +34,17 @@ String getHTML(String url, String post_params) {
} }
String getHTML() { // gets the date and year from time.h library String getHTML() { // gets the date and year from time.h library
struct tm timeinfo; struct tm timeinfo;
char dayInMonth[3]; char dayInYear[4];
char month[3];
char year[5]; char year[5];
if(!getLocalTime(&timeinfo)){ if(!getLocalTime(&timeinfo)){
Serial.println("Failed to obtain time"); Serial.println("Failed to obtain time");
return ""; return "";
} }
strftime(dayInMonth,3, "%d", &timeinfo); sprintf(dayInYear,"%d",timeinfo.tm_yday+1);
sprintf(month,"%d",timeinfo.tm_mon); // the month number has to be in range 0-11!
strftime(year,5, "%Y", &timeinfo); strftime(year,5, "%Y", &timeinfo);
String post_params = "jahr=" + String(year) + "&monat=" + String(month) + "&tag=" + String(dayInMonth); // create post parameters of the form "jahr=2023&monat=2&tag=2" String post_params = "jahr=" + String(year) + "&tagid=" + String(dayInYear); // create post parameters of the form "jahr=YYYY&tagid=III" where III is the day in the year
return getHTML(url, post_params); return getHTML(url, post_params);
} }