Okay guys, this code by SaraJo works perfectly. The instructions are pretty simple.
- Go to this site and follow Step 1. Save the long string you get (OAuth Key), you’ll need this later!
- Paste the code I’ve provided below into a new Sketch in the WebIDE.
- At the top of the code you’ll see a line called
#define TOKEN "OAuth"
. Replace the word OAuth with the long string you got in Step 1. (Be sure you keep the quotes around your OAuth string!) - At the very top of the code you’ll find a line called
char msg[] = "Hi, I'm a tweet from a Spark Core!";
. Replace that sentence with whatever you want to tweet! - That’s it! Flash the sketch to your Core and check your Twitter account!
Caveats: You can only send around one tweet per minute, so don’t run this code in the main loop!
If this works for you guys I’ll wrap it up into a neat little function.
Code:
// Message to Post
char msg[] = "Hi, I'm a tweet from a Spark Core!";
// OAuth Key
#define TOKEN "OAuth"
// Twitter Proxy
#define LIB_DOMAIN "arduino-tweet.appspot.com"
TCPClient client;
void setup()
{
delay(1000);
client.connect(LIB_DOMAIN, 80);
client.println("POST /update HTTP/1.0");
client.println("Host: " LIB_DOMAIN);
client.print("Content-Length: ");
client.println(strlen(msg)+strlen(TOKEN)+14);
client.println();
client.print("token=");
client.print(TOKEN);
client.print("&status=");
client.println(msg);
}
void loop() {
}