Hi,
I want to write code in C using curl library to get output of php page , the output is in xml.
Thanks
Hi,
I want to write code in C using curl library to get output of php page , the output is in xml.
Thanks
What have you tried so far?
I tried the below code:
FILE *pFile = NULL;
pFile = fopen("/tmp/speed_test_config.xml", "wb");
/* keeps the handle to the curl object */
CURL *curl_handle = NULL;
/* to keep the response */
char *response = NULL;
/* initializing curl and setting the url */
curl_handle = curl_easy_init();
curl_easy_setopt(curl_handle, CURLOPT_URL, "speedtest-config.php");
curl_easy_setopt(curl_handle, CURLOPT_HTTPGET, 1);
/* follow locations specified by the response header */
curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);
/* setting a callback function to return the data */
//curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_callback_func);
/* passing the pointer to the response as the callback parameter */
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, &response);
/* perform the request */
curl_easy_perform(curl_handle);
fwrite(response, sizeof(char), max_json_buf_len, pFile);
fclose(pFile);
fprintf(log_fp, "ABHI: Received AP ispeedtest server config response, status code %ld\n", status_code);
/* cleaning all curl stuff */
curl_easy_cleanup(curl_handle);