Chris Styles / Mbed 2 deprecated EA_HTTP

Dependencies:   mbed lwip

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "HTTPClient.h"
00003 
00004 DigitalOut led(LED1);
00005 HTTPClient http;
00006 
00007 /* 
00008   execute a php script that returns the time
00009   
00010   <?php
00011   print strftime('%c');
00012   ?>
00013 
00014 */
00015 
00016 
00017 int main(void) {
00018 
00019   char result[64];
00020   const char url[] = "http://mbed5.dh.bytemark.co.uk/~chris/time.php";
00021   printf ("Fetching from : %s\n",url);
00022   
00023   http.get(url, result);
00024 
00025   // Display the page content:
00026   printf("Result is: %s\n", result);
00027 
00028   // Work is done!
00029   while(1) {
00030     led = !led;
00031     wait(0.2);
00032   }
00033 }