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.
main.cpp
00001 // twitter client test 00002 // written by utaani@ueno.org 00003 00004 #include "mbed.h" 00005 #include "HTTPClient.h" 00006 #define DEBUG 00007 00008 DigitalOut led(LED1); // for finised indicator 00009 HTTPClient http; // twitter client 00010 00011 #ifdef DEBUG 00012 Serial pc(USBTX, USBRX); // for debug 00013 #endif 00014 00015 AnalogIn seed(p15); // for random seed 00016 00017 const char user[] = "username"; 00018 const char pass[] = "password"; 00019 const char url[] = "http://twitter.com/statuses/update.xml"; 00020 00021 int main(void) { 00022 char response[4096]; // buffer for results 00023 char msg[1024]; // buffer for messages 00024 int result,i; 00025 00026 srand(seed.read_u16()); // init random with AnalogIn (for multipul post) 00027 sprintf(msg, "status=This is test from mbed.(%d)", rand()%100); // make message 00028 00029 #ifdef DEBUG 00030 pc.printf("started\r\n"); 00031 #endif 00032 00033 http.auth(user, pass); 00034 result = http.post(url, msg, response, 4096); 00035 00036 #ifdef DEBUG 00037 pc.printf("result=%d\r\n",result); 00038 for(i=0;i<result;i++) { 00039 pc.putc(response[i]); 00040 } 00041 pc.printf("\r\n"); 00042 #endif 00043 00044 // finished loop 00045 while(1) { 00046 led = !led; 00047 wait(0.2); 00048 } 00049 }
Generated on Mon Jul 25 2022 22:39:52 by
1.7.2