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

Committer:
wolfSSL
Date:
Mon Jul 21 11:29:59 2014 +0000
Revision:
0:ca5715c208bf
Twilio phone calls with Dropbox phone book;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wolfSSL 0:ca5715c208bf 1 /* dropbox.c
wolfSSL 0:ca5715c208bf 2 *
wolfSSL 0:ca5715c208bf 3 * Copyright (C) 2006-2014 wolfSSL Inc.
wolfSSL 0:ca5715c208bf 4 *
wolfSSL 0:ca5715c208bf 5 * This file is part of CyaSSL.
wolfSSL 0:ca5715c208bf 6 *
wolfSSL 0:ca5715c208bf 7 * CyaSSL is free software; you can redistribute it and/or modify
wolfSSL 0:ca5715c208bf 8 * it under the terms of the GNU General Public License as published by
wolfSSL 0:ca5715c208bf 9 * the Free Software Foundation; either version 2 of the License, or
wolfSSL 0:ca5715c208bf 10 * (at your option) any later version.
wolfSSL 0:ca5715c208bf 11 *
wolfSSL 0:ca5715c208bf 12 * CyaSSL is distributed in the hope that it will be useful,
wolfSSL 0:ca5715c208bf 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
wolfSSL 0:ca5715c208bf 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
wolfSSL 0:ca5715c208bf 15 * GNU General Public License for more details.
wolfSSL 0:ca5715c208bf 16 *
wolfSSL 0:ca5715c208bf 17 * You should have received a copy of the GNU General Public License
wolfSSL 0:ca5715c208bf 18 * along with this program; if not, write to the Free Software
wolfSSL 0:ca5715c208bf 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
wolfSSL 0:ca5715c208bf 20 */
wolfSSL 0:ca5715c208bf 21
wolfSSL 0:ca5715c208bf 22 #include "mbed.h"
wolfSSL 0:ca5715c208bf 23 #include "EthernetInterface.h"
wolfSSL 0:ca5715c208bf 24 #include "HTTPClient.h"
wolfSSL 0:ca5715c208bf 25
wolfSSL 0:ca5715c208bf 26 extern HTTPClient http;
wolfSSL 0:ca5715c208bf 27
wolfSSL 0:ca5715c208bf 28 HTTPResult dropbox_get(const char *url, char *buff, int size)
wolfSSL 0:ca5715c208bf 29 {
wolfSSL 0:ca5715c208bf 30 HTTPResult ret ;
wolfSSL 0:ca5715c208bf 31 #define LOCATION_SIZE 128
wolfSSL 0:ca5715c208bf 32 static char location[LOCATION_SIZE] ;
wolfSSL 0:ca5715c208bf 33 static const char HeaderLines[] =
wolfSSL 0:ca5715c208bf 34 "User-Agent: curl/7.33.0\r\n"
wolfSSL 0:ca5715c208bf 35 "Accept: */*\r\n" ;
wolfSSL 0:ca5715c208bf 36
wolfSSL 0:ca5715c208bf 37 http.setHeader(HeaderLines) ;
wolfSSL 0:ca5715c208bf 38 http.setLocationBuf(location, LOCATION_SIZE) ;
wolfSSL 0:ca5715c208bf 39
wolfSSL 0:ca5715c208bf 40 ret = http.get(url, buff, size) ;
wolfSSL 0:ca5715c208bf 41 if ((ret == HTTP_OK) || (ret == HTTP_REDIRECT)) {
wolfSSL 0:ca5715c208bf 42 if(ret == HTTP_REDIRECT) {
wolfSSL 0:ca5715c208bf 43 /* goto next */
wolfSSL 0:ca5715c208bf 44 }
wolfSSL 0:ca5715c208bf 45 } else {
wolfSSL 0:ca5715c208bf 46 printf("++ Err = %d - HTTP ret = %d ++\n",
wolfSSL 0:ca5715c208bf 47 ret, http.getHTTPResponseCode());
wolfSSL 0:ca5715c208bf 48 return ret ;
wolfSSL 0:ca5715c208bf 49 }
wolfSSL 0:ca5715c208bf 50
wolfSSL 0:ca5715c208bf 51 if(ret != HTTP_REDIRECT) {
wolfSSL 0:ca5715c208bf 52 printf("No Redirection. Not reached at the contents.") ;
wolfSSL 0:ca5715c208bf 53 } else {
wolfSSL 0:ca5715c208bf 54 ret = http.get(location, buff, size) ;
wolfSSL 0:ca5715c208bf 55 if ((ret == HTTP_OK) || (ret == HTTP_REDIRECT)) {
wolfSSL 0:ca5715c208bf 56 /* goto next */
wolfSSL 0:ca5715c208bf 57 } else {
wolfSSL 0:ca5715c208bf 58 printf("++ Err = %d - HTTP ret = %d ++\n",
wolfSSL 0:ca5715c208bf 59 ret, http.getHTTPResponseCode());
wolfSSL 0:ca5715c208bf 60 return ret ;
wolfSSL 0:ca5715c208bf 61 }
wolfSSL 0:ca5715c208bf 62 }
wolfSSL 0:ca5715c208bf 63 }