From 653950c4c26d0566de7c532da1273c3d1abe3eee Mon Sep 17 00:00:00 2001 From: Jakob Olsson <jakobols@kth.se> Date: Wed, 9 May 2018 09:01:15 +0200 Subject: [PATCH] works now, need add your json parsing etc, perform in two setps --- libmobile.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libmobile.c b/libmobile.c index c9102e2..16579c6 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); -- GitLab