Twilio phone calls by Dropbox phone book
Dependencies: EthernetInterface HTTPClient mbed-rtos mbed-src
dropbox.cpp
00001 /* dropbox.c 00002 * 00003 * Copyright (C) 2006-2014 wolfSSL Inc. 00004 * 00005 * This file is part of CyaSSL. 00006 * 00007 * CyaSSL is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * CyaSSL is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 00020 */ 00021 00022 #include "mbed.h" 00023 #include "EthernetInterface.h" 00024 #include "HTTPClient.h" 00025 00026 extern HTTPClient http; 00027 00028 HTTPResult dropbox_get(const char *url, char *buff, int size) 00029 { 00030 HTTPResult ret ; 00031 #define LOCATION_SIZE 128 00032 static char location[LOCATION_SIZE] ; 00033 static const char HeaderLines[] = 00034 "User-Agent: curl/7.33.0\r\n" 00035 "Accept: */*\r\n" ; 00036 00037 http.setHeader(HeaderLines) ; 00038 http.setLocationBuf(location, LOCATION_SIZE) ; 00039 00040 ret = http.get(url, buff, size) ; 00041 if ((ret == HTTP_OK) || (ret == HTTP_REDIRECT)) { 00042 if(ret == HTTP_REDIRECT) { 00043 /* goto next */ 00044 } 00045 } else { 00046 printf("++ Err = %d - HTTP ret = %d ++\n", 00047 ret, http.getHTTPResponseCode()); 00048 return ret ; 00049 } 00050 00051 if(ret != HTTP_REDIRECT) { 00052 printf("No Redirection. Not reached at the contents.") ; 00053 } else { 00054 ret = http.get(location, buff, size) ; 00055 if ((ret == HTTP_OK) || (ret == HTTP_REDIRECT)) { 00056 /* goto next */ 00057 } else { 00058 printf("++ Err = %d - HTTP ret = %d ++\n", 00059 ret, http.getHTTPResponseCode()); 00060 return ret ; 00061 } 00062 } 00063 }
Generated on Mon Jul 25 2022 21:31:28 by 1.7.2