diff --git a/libmobile.c b/libmobile.c index c9102e22c2fa4e5a724d3e321fb7c2bcafcd40d4..16579c61a19138eaa9012a5a5e872f45832fe032 100644 --- a/libmobile.c +++ b/libmobile.c @@ -50,7 +50,7 @@ static char *request(const char *url) char *data = NULL; long code; - curl_global_init(CURL_GLOBAL_ALL); + //curl_global_init(CURL_GLOBAL_ALL); curl = curl_easy_init(); printf("init curl session\n"); if(!curl) @@ -67,12 +67,18 @@ static char *request(const char *url) curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_URL, url); + curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""); //Read locally stored cookies curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "cookies.txt"); //Save the cookie from the server to cookie.txt - curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "cookies.txt"); //Read locally stored cookies - sleep(1); - curl_easy_setopt(curl, CURLOPT_URL, "http://192.168.8.1/api/monitoring/status"); + //curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_response); + //curl_easy_setopt(curl, CURLOPT_WRITEDATA, &write_result); + + + status = curl_easy_perform(curl); + curl_easy_setopt(curl, CURLOPT_URL, "http://192.168.8.1/api/device/information"); + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); + curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "cookies.txt"); //Read locally stored cookies curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_response); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &write_result);