c - curl not working when pasting the same url which works in browser address bar -


i trying use libcurl c api post thing on site. url works when access browser. copied same browser bar , accessing in program. program hangs in curl_easy_perform call , never returns. provide write_callback never gets invoked. whats wrong piece of code below

for privacy reasons removed url piece of code below .

int main(void) {     curlcode res;      curl *curl = curl_easy_init();     if(curl) {         curl_easy_setopt(curl, curlopt_url, "");          curl_easy_setopt(curl, curlopt_post, 1);         //curl_easy_setopt(curl, curlopt_connecttimeout, 1l );         //curl_easy_setopt(curl, curlopt_timeout, 1l );         curl_easy_setopt(curl, curlopt_writefunction, write_callback);         res = curl_easy_perform(curl);         if (res != curle_ok) fprintf(stderr,"failed: %s", curl_easy_strerror(res));         curl_easy_cleanup(curl);     }     return -1; } 

you need set curlopt_postfields , curlopt_postfieldsize well.

so if post looks http://awesome.com/superpost.html?blah=hi

there decent examples on curl site:

note: you'll want escape post field key/values curl_escape


Comments