simplepost.c 949 B

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