Bitwise
Bitwise

Reputation: 8461

Understanding capabilities of Twilio.

I'm trying to build a small application that will save an incoming phone number to the database and have a UI that will allow an administrator to send out blast messages to the numbers in the database. If anyone has experience with this I'd love some good documentation or advice on how to accomplish this task. If it is possible?

Upvotes: 1

Views: 116

Answers (1)

John Hascall
John Hascall

Reputation: 9416

Here's some excerpts from my Twilio SMS app which might give you a sense of how you might interact with Twilio:

static const char *     sms_host        = "api.twilio.com";
static const char *     sms_user        = "AC(redacted)";
static const char *     sms_pass        = "(redacted)";
static const char *     sms_from        = "15155551212";  /* our purchased # */

static char * twilioSendTextUrl (
        void
) {
        return strBuild(NULL,
            "https://%s:%s@%s/2010-04-01/Accounts/%s/SMS/Messages",
            sms_user, sms_pass, sms_host, sms_user);
}

static char * twilioSendTextRequest (
        const char *    to,
        const char *    text
) {
        if ((to == NULL) || (text == NULL)) return NULL;
        return strBuild(NULL,
            "From=+%s"  "&"
            "To=+%s"    "&"
            "Body=%s",
            sms_from,
            to,
            cgiEncode(text)
        );
}

static char * doPost (
        const char *    url,
        const char *    postdata
) {
        CURL *  curl    = curl_easy_init();
        int     ces;

        curl_easy_setopt(curl, CURLOPT_URL, url);
        curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postdata);
        ...
        ces = curl_easy_perform(curl);
        curl_easy_cleanup(curl);
        ...
}

ret = doPost(twilioSendTextUrl(), twilioSendTextRequest(number, message));

Upvotes: 4

Related Questions