Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface HTTPClient mbed-rtos mbed
main.cpp
- Committer:
- kanpapa
- Date:
- 2013-06-15
- Revision:
- 3:77c1d75e96a6
- Parent:
- 0:05d2322a3ff3
- Child:
- 4:064d41eb0a16
File content as of revision 3:77c1d75e96a6:
#include "mbed.h"
#include "EthernetInterface.h"
#include "HTTPClient.h"
EthernetInterface eth;
HTTPClient twitter;
char str[512];
int main()
{
eth.init(); //Use DHCP
eth.connect();
//POST data
HTTPMap map;
HTTPText inText(str, 512);
map.put("status", "I am tweeting from my mbed!");
printf("\nTrying to post data...\n");
twitter.basicAuth("myuser", "mypass"); //We use basic authentication, replace with you account's parameters
int ret = twitter.post("http://api.supertweet.net/1.1/statuses/update.json", map, &inText);
if (!ret)
{
printf("Executed POST successfully - read %d characters\n", strlen(str));
printf("Result: %s\n", str);
}
else
{
printf("Error - ret = %d - HTTP return code = %d\n", ret, twitter.getHTTPResponseCode());
}
eth.disconnect();
while(1) {
}
}