simplepost.c 976 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*****************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * $Id: simplepost.c,v 1.1 2002/06/19 12:30:12 bagder Exp $
  9. */
  10. #include <stdio.h>
  11. #include <curl/curl.h>
  12. int main(void)
  13. {
  14. CURL *curl;
  15. CURLcode res;
  16. char *postthis="moo mooo moo moo";
  17. curl = curl_easy_init();
  18. if(curl) {
  19. curl_easy_setopt(curl, CURLOPT_URL, "http://posthere.com");
  20. curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postthis);
  21. /* if we don't provide POSTFIELDSIZE, libcurl will strlen() by
  22. itself */
  23. curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(postthis));
  24. res = curl_easy_perform(curl);
  25. /* always cleanup */
  26. curl_easy_cleanup(curl);
  27. }
  28. return 0;
  29. }