Twitter API 1.1 test program. (use SuperTweet.net)
Dependencies: EthernetInterface HTTPClient mbed-rtos mbed
main.cpp
00001 #include "mbed.h" 00002 #include "EthernetInterface.h" 00003 #include "HTTPClient.h" // basicauth enabled. http://mbed.org/users/kazushi2008/code/HTTPClient/ 00004 00005 EthernetInterface eth; 00006 HTTPClient twitter; 00007 char str[512]; 00008 00009 int main() 00010 { 00011 eth.init(); //Use DHCP 00012 00013 eth.connect(); 00014 00015 //POST data 00016 HTTPMap map; 00017 HTTPText inText(str, 512); 00018 map.put("status", "I am tweeting from my mbed!"); 00019 00020 printf("\nTrying to post data...\n"); 00021 twitter.basicAuth("myuser", "mypass"); //We use basic authentication, replace with you account's parameters 00022 int ret = twitter.post("http://api.supertweet.net/1.1/statuses/update.json", map, &inText); 00023 if (!ret) 00024 { 00025 printf("Executed POST successfully - read %d characters\n", strlen(str)); 00026 printf("Result: %s\n", str); 00027 } 00028 else 00029 { 00030 printf("Error - ret = %d - HTTP return code = %d\n", ret, twitter.getHTTPResponseCode()); 00031 } 00032 00033 eth.disconnect(); 00034 00035 while(1) { 00036 } 00037 }
Generated on Mon Jul 18 2022 17:56:32 by 1.7.2