Commit dbeac73a authored by Michael Tross's avatar Michael Tross

improve parsing of api response

fix parsing of "expire_in"
add more ignored keys
parent 64b9dc00
......@@ -323,11 +323,14 @@ netatmo_get_token()
netatmo.refresh_token = strdup(json_object_get_string(val));
configChanged = true;
}
} else if (!strcmp(key, "expires_in")) {
} else if (!strcmp(key, "expire_in")) {
if (type == json_type_int) {
int exp = json_object_get_int(val);
g_access_token_valid_until = time(NULL) + exp - 120; // 2 minutes before expiration
vdc_report(LOG_INFO, "network: token expire_in: %d -> valid until %ld\n", exp, g_access_token_valid_until);
}
} else if (!strcmp(key, "scope")) {
// ignore
} else if (!strcmp(key, "error")) {
if (type == json_type_string) {
vdc_report(LOG_ERR, "network: token reponse contains error: %s\n", json_object_get_string(val));
......@@ -586,12 +589,18 @@ int netatmo_get_devices()
// deprecated devicelist return modules as top level array
parseModule(val, type);
} else if (!strcmp(key, "user")) {
// ignore
} else {
vdc_report(LOG_WARNING, "network: getstationsdata unknown device type \"%s\"\n", key);
vdc_report(LOG_WARNING, "network: getstationsdata unknown toplevel object \"%s\"\n", key);
}
}
}
} else if (!strcmp(key, "time_exec") || !strcmp(key, "time_server")) {
// ignore
} else {
vdc_report(LOG_WARNING, "network: getstationsdata unknown key \"%s\"\n", key);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment