add twilio example.
This commit is contained in:
parent
bde8ad395e
commit
caace4ca89
18
twilio_example.h
Normal file
18
twilio_example.h
Normal file
@ -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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user