setcUrlOptions();\r
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback); \r
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&xml_page);\r
+ // save the sessoin id that is given back by the server in a cookie\r
+ curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "cookiejar.txt");\r
// use POST for login variables\r
curl_easy_setopt(curl, CURLOPT_POST, TRUE);\r
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postMessage.c_str());\r
curl_easy_setopt(curl, CURLOPT_URL, login_url.c_str() );\r
\r
// perform online request\r
+ connection = 1;\r
CURLcode res = curl_easy_perform(curl);\r
- // if something goes wrong 'connection' is set to '0'\r
- if(strcmp(curl_easy_strerror(res), "no error") == 0) connection = 1;\r
- else connection = 0;\r
-\r
+ if( res != 0 ) {\r
+ toLog("curl login error\n");\r
+ toLog(curl_easy_strerror(res));\r
+ connection = 0;\r
+ }\r
+ \r
if (connection == 1){\r
std::string check_page = xml_page.memory;\r
int test = (int)check_page.find("login"); //logged\r
curl_easy_setopt(curl, CURLOPT_URL, search_url.c_str());\r
\r
// perform the online search \r
- CURLcode res = curl_easy_perform(curl);\r
- if(strcmp(curl_easy_strerror(res), "no error") == 0) connection = 1;\r
- else connection = 0;\r
+ connection = 1;\r
+ CURLcode res = curl_easy_perform(curl);\r
+ if( res != 0 ) {\r
+ toLog("curl login error\n");\r
+ toLog(curl_easy_strerror(res));\r
+ connection = 0;\r
+ }\r
\r
result = xml_page.memory;\r
-//printf("%s/n", result.c_str());\r
+ toLog( result.c_str() );\r
\r
// free the memory\r
if(xml_page.memory){\r
curl_easy_setopt(curl, CURLOPT_URL, getxml_url.c_str() );\r
\r
// get it!\r
+ connection = 1;\r
CURLcode res = curl_easy_perform(curl);\r
- if(strcmp(curl_easy_strerror(res), "no error") == 0) connection = 1;\r
- else connection = 0;\r
+ if( res != 0 ) {\r
+ toLog("curl login error\n");\r
+ toLog(curl_easy_strerror(res));\r
+ connection = 0;\r
+ }\r
}\r
}\r
//------------------------------------------------------------------------\r
curl_easy_setopt(curl, CURLOPT_URL, audioURL.c_str() );\r
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, audioFileWrite);\r
curl_easy_setopt(curl, CURLOPT_WRITEDATA, theFile);\r
+\r
+ connection = 1;\r
CURLcode res = curl_easy_perform(curl);\r
- if(strcmp(curl_easy_strerror(res), "no error") == 0) connection = 1;\r
- else connection = 0;\r
+ if( res != 0 ) {\r
+ toLog("curl login error\n");\r
+ toLog(curl_easy_strerror(res));\r
+ connection = 0;\r
+ }\r
\r
fclose(theFile);\r
}\r