1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
void test001()
{
cout << "test001" << "\n";
CURL *curl;
CURLcode res;
struct curl_slist *headers=NULL;
headers = curl_slist_append(headers, "Content-Type: text/xml");
const char *url = "http://localhost/test.php";
/* get a curl handle */
curl = curl_easy_init();
if(curl)
{
curl_easy_setopt(curl,CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_POST, 1);
const char* postmess = "cheval";
printf(postmess);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postmess);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(postmess) );
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_perform(curl);
curl_slist_free_all(headers);
/* always cleanup */
curl_easy_cleanup(curl);
}
exit(0);
} |
Partager