Twilio phone calls by Dropbox phone book

Dependencies:   EthernetInterface HTTPClient mbed-rtos mbed

This simple Twilio example works with HTTPS based Twilio API from mbed, makes phone calls and talks text speech message by referring phone book file in Dropbox.

For using this example:

- Prepare mbed with Ethernet connection.

- Go to http://twilio.com, and sign up.

- Copy Twilio Sid, Token, phone number and TwiML URL in twilio.cpp.

static char twilio_AccountSid[] = "TWILIO_ACCOUNT_SID" ;
static char twilio_AuthToken[]  = "AUTH_TOKEN" ;
static const char twilio_From[] = "PHONE_NUMBER_FROM" ;
static const char twilio_Url[]  = "http://twimlbin.com/TWIML_PATH" ;

- Copy Dropbox file link URL to dropbox.cpp.

static char Dropbox_URL[] = "https://www.dropbox.com/PHONE_LIST_FILE" ;

- The demo makes a call from Twilio to the phone numbers listed on the Dropbox phone book. Phone book is list of the number CSV file.

- Set up a TwiML web page defining Twilio action, set the url to twilio_Url.

TwiML first step example:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
	<Say language="ja-JP">もしもし。聞こえますか?こちらツイリオです</Say>
</Response>

- Build, download it to mbed, and you will get a call on your phone.

Have fun!

For FRDM-k64f: http://mbed.org/users/wolfSSL/code/CyaSSL-Twilio-Dropbox-FRDM/

日本語:http://mbed.org/users/wolfSSL/code/CyaSSL-Twilio/wiki/CyaSSL-Twilio-Dropbox-jp

dropbox.cpp

Committer:
wolfSSL
Date:
2014-07-21
Revision:
0:ca5715c208bf

File content as of revision 0:ca5715c208bf:

/* dropbox.c
 *
 * Copyright (C) 2006-2014 wolfSSL Inc.
 *
 * This file is part of CyaSSL.
 *
 * CyaSSL is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * CyaSSL is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 */

#include "mbed.h"
#include "EthernetInterface.h"
#include "HTTPClient.h"

extern HTTPClient http;

HTTPResult dropbox_get(const char *url, char *buff, int size)
{
    HTTPResult ret ;
#define LOCATION_SIZE 128
    static char location[LOCATION_SIZE] ;
    static const char HeaderLines[] =
        "User-Agent: curl/7.33.0\r\n"
        "Accept: */*\r\n" ;

    http.setHeader(HeaderLines) ;
    http.setLocationBuf(location, LOCATION_SIZE) ;

    ret = http.get(url, buff, size) ;
    if ((ret == HTTP_OK) || (ret == HTTP_REDIRECT)) {
        if(ret == HTTP_REDIRECT) {
            /* goto next */
        }
    } else {
        printf("++ Err = %d - HTTP ret = %d ++\n",
               ret, http.getHTTPResponseCode());
        return ret ;
    }

    if(ret != HTTP_REDIRECT) {
        printf("No Redirection. Not reached at the contents.") ;
    } else {
        ret = http.get(location, buff, size) ;
        if ((ret == HTTP_OK) || (ret == HTTP_REDIRECT)) {
            /* goto next */
        } else {
            printf("++ Err = %d - HTTP ret = %d ++\n",
                   ret, http.getHTTPResponseCode());
            return ret ;
        }
    }
}