Twitter client that can be directly tweet. (Intermediate server is not required.)
Dependencies: EthernetInterface HTTPClient-wolfSSL NTPClient OAuth4Tw mbed-rtos mbed wolfSSL
Fork of OAuth4Tw by
Revision 1:4dfa9d41f414, committed 2014-12-14
- Comitter:
- ban4jp
- Date:
- Sun Dec 14 08:08:14 2014 +0000
- Parent:
- 0:00a2d3570824
- Child:
- 2:392b8e079c7a
- Commit message:
- Twitter client that can be directly tweet. (Intermediate server is not required.)
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/EthernetInterface.lib Sun Dec 14 08:08:14 2014 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/mbed_official/code/EthernetInterface/#de796e2a5e98
--- a/EthernetNetIf.lib Sun May 20 14:51:54 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mamezu/code/EthernetNetIf/#0f6c82fcde82
--- a/HTTPClient.lib Sun May 20 14:51:54 2012 +0000 +++ b/HTTPClient.lib Sun Dec 14 08:08:14 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mamezu/code/HTTPClient/#62fac7f06c8d +http://developer.mbed.org/users/wolfSSL/code/HTTPClient/#a9ecee69c6b5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/NTPClient.lib Sun Dec 14 08:08:14 2014 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/ban4jp/code/NTPClient/#c70ed0bfab2e
--- a/OAuth4Tw.lib Sun May 20 14:51:54 2012 +0000 +++ b/OAuth4Tw.lib Sun Dec 14 08:08:14 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/takahashim/code/OAuth4Tw/#0048b264a3ad +http://developer.mbed.org/users/ban4jp/code/OAuth4Tw/#0036880e6f71
--- a/main.cpp Sun May 20 14:51:54 2012 +0000 +++ b/main.cpp Sun Dec 14 08:08:14 2014 +0000 @@ -1,23 +1,49 @@ #include <string.h> #include "mbed.h" -#include "EthernetNetIf.h" +#include "EthernetInterface.h" +#include "NTPClient.h" #include "OAuth4Tw.h" DigitalOut myled(LED1); -EthernetNetIf eth; +EthernetInterface eth; +NTPClient ntp; + +OAuth4Tw oa4t("XXXXXXXXXXXXXXXXXXXXXXXXX", // Consumer key + "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", // Consumer secret + "000000000-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", // Access token + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); // Access token secret -int main() { - EthernetErr ethErr = eth.setup(); - if (ethErr) { - printf("Error %d in setup.\n", ethErr); +int main() +{ + int ret = eth.init(); //Use DHCP + if (!ret) { + printf("Initialized, MAC: %s\n", eth.getMACAddress()); + } else { + printf("Error eth.init() - ret = %d\n", ret); return -1; } - OAuth4Tw oa4t("XXXXXXXXXXXXXXXXXXXXXX", // Consumer key - "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", // Consumer secret - "000000000-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", // Access token - "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); // Access token secret - std::string uri = "http://api.twitter.com/statuses/update.xml"; + ret = eth.connect(); + if (!ret) { + printf("Connected, IP: %s, MASK: %s, GW: %s\n", + eth.getIPAddress(), eth.getNetworkMask(), eth.getGateway()); + } else { + printf("Error eth.connect() - ret = %d\n", ret); + return -1; + } + + printf("Trying to update time...\n"); + + //ret = ntp.setTime("pool.ntp.org"); + ret = ntp.setTime("ntp.nict.jp"); + if (!ret) { + time_t ctTime = time(NULL); + printf("Time is set to (UTC): %s\n", ctime(&ctTime)); + } else { + printf("Error\n"); + } + + std::string uri = "https://api.twitter.com/1.1/statuses/update.json"; uri += "?status="; uri += OAuth4Tw::url_escape("Hello World!"); std::string postarg;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-rtos.lib Sun Dec 14 08:08:14 2014 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/mbed_official/code/mbed-rtos/#f1ef95efa5ad
--- a/mbed.bld Sun May 20 14:51:54 2012 +0000 +++ b/mbed.bld Sun Dec 14 08:08:14 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/737756e0b479 +http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5 \ No newline at end of file