From caace4ca89a6748f53e37fa87656e6c30e39acd9 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 19 Aug 2014 14:14:54 -0700 Subject: [PATCH] add twilio example. --- twilio_example.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 twilio_example.h diff --git a/twilio_example.h b/twilio_example.h new file mode 100644 index 0000000..84d48fd --- /dev/null +++ b/twilio_example.h @@ -0,0 +1,18 @@ +#define TWILIO_SEND +#define TWILIO_API_SIZE (450 * sizeof(char)) + +static int +twilio_send(const char *msg, int async) { + char *cmd = (char *)malloc(TWILIO_API_SIZE); + int r = snprintf(cmd, TWILIO_API_SIZE, + "curl -X POST https://api.twilio.com/2010-04-01/Accounts/{account}/SMS/Messages.json" + " -u {username}:{password}" + " --data-urlencode 'From=+{twilio-number}'" + " --data-urlencode 'To=+{phone-number}'" + " --data-urlencode 'Body=%s'" + "%s", msg, async ? " &" : ""); + if (r == -1) return r; + r = system(cmd); + free(cmd); + return r; +}