eichi kowata / Mbed 2 deprecated geiger

Dependencies:   EthernetNetIf NTPClient_NetServices mbed ConfigFile

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers twitter.c Source File

twitter.c

00001 /***********************************
00002 
00003  twitter.c
00004 
00005 ***********************************/
00006 #include "mbed.h"
00007 #include "HTTPClient.h"
00008 #include "TextLCD.h"
00009 
00010 #define DEBUG
00011 
00012 //LCD
00013 extern TextLCD lcd;
00014 extern HTTPClient commonClient;
00015 
00016 extern void printable_msg(char*);
00017 extern int GetStatus(char *, char *, char *);
00018 
00019 char id[128];
00020 char password[128];
00021 
00022 /**************************************
00023 * Output to Twitter *
00024 ***************************************/
00025 void twitter_output(void){
00026     char msg[256];
00027     msg[0]='\0';
00028     printable_msg(msg);
00029 
00030     HTTPMap h_msg;
00031     h_msg["status"] = msg; //A good example of Key/Value pair use with Web APIs
00032 
00033     commonClient.basicAuth(id, password);   //We use basic authentication, replace with you account's parameters
00034 #ifdef DEBUG
00035 //  printf("twitter\r\n");
00036   printf("%s,%s\r\n",id,password);
00037 #endif
00038     //No need to retieve data sent back by the server
00039     HTTPResult r = commonClient.post("http://api.supertweet.net/1/statuses/update.xml", h_msg, NULL);
00040 
00041 #ifdef DEBUG
00042     if( r == HTTP_OK ){
00043         printf("%s",msg);
00044         printf("Tweet sent with success!\n");
00045     }else{
00046         printf("Problem during tweeting, return code %d\n", r);
00047     }
00048 #endif
00049 }
00050 
00051 void twitter_setup(){
00052     GetStatus("/local/TWITTER.CFG","ID",id);
00053     GetStatus("/local/TWITTER.CFG","PASS",password);
00054     printf("twitter ID=%s, password=%s\r\n",id,password);
00055     lcd.cls();
00056     lcd.locate(0,0);
00057     lcd.printf("Twitter ID=%s",id);
00058     wait(2);
00059 }
00060 
00061