Connect to twitter.com and copies this webpage to a file.
Dependencies: EthernetInterface3 HTTPSClient TLS_axTLS mbed-rtos mbed
This example shows how to use the HTTPSClient library by copying the content of this webpage to a file. Before running this program, you must download these certificates and copy them to the mbed. After running this program, a file called index.htm has been created and you can open it with your favorite browser to display the webpage the mbed have just downloaded.
Revision 3:6d25972a1b21, committed 2013-09-12
- Comitter:
- feb11
- Date:
- Thu Sep 12 09:06:57 2013 +0000
- Parent:
- 2:e3807a060fa5
- Child:
- 4:99746155e2ef
- Commit message:
- update lib
Changed in this revision
--- a/HTTPSClient.lib Thu Sep 05 14:29:02 2013 +0000 +++ b/HTTPSClient.lib Thu Sep 12 09:06:57 2013 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/feb11/code/HTTPSClient/#6d7bc51cc77b +http://mbed.org/users/feb11/code/HTTPSClient/#18af58231990
--- a/TLS.lib Thu Sep 05 14:29:02 2013 +0000 +++ b/TLS.lib Thu Sep 12 09:06:57 2013 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/feb11/code/TLS/#fd7a4452443c +http://mbed.org/users/feb11/code/TLS/#20a4202bc658
--- a/main.cpp Thu Sep 05 14:29:02 2013 +0000 +++ b/main.cpp Thu Sep 12 09:06:57 2013 +0000 @@ -7,16 +7,16 @@ download them from this link: http://mbed.org/media/uploads/feb11/certificates-twitter.zip */ - + #include "mbed.h" #include "EthernetInterface.h" #include "CertificateManager.h" #include "HTTPSClient.h" - + const char host[] = "twitter.com"; const char request[] = "https://twitter.com"; LocalFileSystem local("local"); - + int main() { set_time(1378370406); @@ -28,7 +28,7 @@ printf("Error with EthernetInterface\n\r"); return -1; } - + /* Loading certificates in precomputed mode */ CertificateManager::add("/local/cert1.der"); CertificateManager::add("/local/cert2.der"); @@ -38,7 +38,7 @@ printf("Failed to load certificates\n"); return -1; } - + /* Now, let's connect to twitter.com */ HTTPSClient client; if(!client.connect(host)) @@ -91,7 +91,7 @@ fwrite(buffer, 1, read, fp); totalRead += read; } - + /* We're done, let's close everything */ fclose(fp); printf("Disconnecting from %s\n", host); @@ -99,4 +99,4 @@ eth.disconnect(); return 0; -} +} \ No newline at end of file