A simple demo how to use the HTTPClient.
You might find this useful: [http://mbed.org/users/chris/programs/EA_Twitter]
It twitters a message to your twitter account.
Library
Import Library:
http://mbed.org/projects/cookbook/svn/EMAC/lwip/trunk
or import precompiled Library:
http://mbed.org/projects/cookbook/svn/EMAC/lwip/precomp
Import Example program:
http://mbed.org/projects/cookbook/svn/EMAC/lwip/examples/HTTPClient
Hello World
#include "mbed.h"
#include "HTTPClient.h"
using namespace std;
DigitalOut led(LED1);
HTTPClient http;
const char user[] = "<username>";
const char pass[] = "<password>";
const char msg[] = "status=<message>";
const char url[] = "http://twitter.com/statuses/update.xml";
int main(void) {
http.auth(user, pass);
http.post(url, msg);
while(1) {
led = !led;
wait(0.2);
}
}
|
API
| HTTPClient | A simple Class to fetch HTTP Pages. |
| Functions | |
| HTTPClient | Creates an HTTPClient object. |
| ~HTTPClient | Destroys the HTTPClient class. |
| headers | Add header additional Information to the next post or get requests. |
| auth | Enables basic authentication. |
| get | A simple get-request just insert the url. |
| get | A simple get-request just insert the url and a FILE Pointer. |
| post | A simple post-request just insert the url. |
| post | A simple get-request just insert the url and a FILE Pointer. |
| post | A simple get-request just insert the url and a two FILE Pointers to send the content of the file out and store you results. |
| post | A simple get-request just insert the url and a two FILE Pointers to send the content of the file out and store you results. |
| timeout | Sets the timout for a HTTP request. |
Resources
Development Log