http-post.c 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*****************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * $Id: http-post.c,v 1.1 2002/01/10 09:00:02 bagder Exp $
  9. */
  10. #include <stdio.h>
  11. #include <curl/curl.h>
  12. int main(void)
  13. {
  14. CURL *curl;
  15. CURLcode res;
  16. curl = curl_easy_init();
  17. if(curl) {
  18. /* First set the URL that is about to receive our POST. This URL can
  19. just as well be a https:// URL if that is what should receive the
  20. data. */
  21. curl_easy_setopt(curl, CURLOPT_URL, "http://postit.example.com/moo.cgi");
  22. /* Now specify the POST data */
  23. curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "name=daniel&project=curl");
  24. /* Perform the request, res will get the return code */
  25. res = curl_easy_perform(curl);
  26. /* always cleanup */
  27. curl_easy_cleanup(curl);
  28. }
  29. return 0;
  30. }