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