Skip to content

Instantly share code, notes, and snippets.

@domnikl
Last active January 7, 2020 08:14
Show Gist options
  • Save domnikl/9d86859354c4435b517ea4a787c15bc2 to your computer and use it in GitHub Desktop.
Save domnikl/9d86859354c4435b517ea4a787c15bc2 to your computer and use it in GitHub Desktop.
cURL example to post to make.ifttt.com
/*.o
/example
#include <stdio.h>
#include <curl/curl.h>
int main()
{
curl_global_init(CURL_GLOBAL_ALL);
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if (curl)
{
curl_easy_setopt(curl, CURLOPT_URL, "https://maker.ifttt.com/trigger/<event>/with/key/<key>");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "value1=1&value2=2&value3=3");
res = curl_easy_perform(curl);
if (res != CURLE_OK)
{
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
}
curl_easy_cleanup(curl);
}
curl_global_cleanup();
return 0;
}
CC = gcc
CFLAGS = -std=c99 -Wall -fstack-protector -D_FORTIFY_SOURCE=2 -O2 -I/usr/local/include -lcurl
DEPS =
OBJ = example.o
example: $(OBJ)
gcc -o $@ $^ $(CFLAGS)
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
clean:
rm ./*.o
rm example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment