Created
September 9, 2010 17:06
-
-
Save joewilliams/572182 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
mostly stolen from: | |
http://github.com/bagder/curl/blob/master/docs/examples/http-post.c | |
to compile: | |
gcc -lcurl post.c -o post | |
*/ | |
#include <curl/curl.h> | |
int main(void) | |
{ | |
CURL *curl; | |
CURLcode res; | |
struct curl_slist *headerlist=NULL; | |
char *url; | |
char *data; | |
url = "http://localhost:5984/joe"; | |
data = "{\"test\":\"test\"}"; | |
curl = curl_easy_init(); | |
if(curl) { | |
curl_easy_setopt(curl, CURLOPT_URL, url); | |
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); | |
headerlist = curl_slist_append(headerlist, "Content-Type: application/json"); | |
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist); | |
res = curl_easy_perform(curl); | |
curl_easy_cleanup(curl); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment