Twitter API 1.1 test program. (use SuperTweet.net)

Dependencies:   EthernetInterface HTTPClient mbed-rtos mbed mpl115a2

MPL115A2を使って気温と気圧をツイートするプログラムです。

Files at this revision

API Documentation at this revision

Comitter:
kanpapa
Date:
Sat Jun 22 11:01:14 2013 +0000
Commit message:
Release version.

Changed in this revision

EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
HTTPClient.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
mpl115a2.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterface.lib	Sat Jun 22 11:01:14 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/EthernetInterface/#40640efbfcae
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTTPClient.lib	Sat Jun 22 11:01:14 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/kazushi2008/code/HTTPClient/#cf5d7427a9ec
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Jun 22 11:01:14 2013 +0000
@@ -0,0 +1,51 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+#include "HTTPClient.h" // basicauth enabled. http://mbed.org/users/kazushi2008/code/HTTPClient/
+#include "MPL115A2.h"
+
+I2C i2c(p9, p10);        // sda, scl
+Serial pc(USBTX, USBRX); // tx, rx
+
+MPL115A2 p_sensor(&i2c);
+
+EthernetInterface eth;
+HTTPClient twitter;
+char str[512];
+
+int main() 
+{
+    char info[128];
+    
+    p_sensor.begin();   
+    p_sensor.ReadSensor();
+    
+    sprintf(info, "I am tweeting from my mbed! Pressure = %f, Temperature = %f",  p_sensor.GetPressure(),p_sensor.GetTemperature());
+    printf("%s",info);
+
+    eth.init(); //Use DHCP
+
+    eth.connect();
+        
+    //POST data
+    HTTPMap map;
+    HTTPText inText(str, 512);
+    map.put("status", info);
+
+    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) {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Sat Jun 22 11:01:14 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#58b30ac3f00e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Jun 22 11:01:14 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/b3110cd2dd17
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpl115a2.lib	Sat Jun 22 11:01:14 2013 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/joeh/code/mpl115a2/#6dbe3322f203