-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTwitter.ino
More file actions
37 lines (31 loc) · 1.15 KB
/
Twitter.ino
File metadata and controls
37 lines (31 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//Twitter Setup
// supertweet.net username:password in base64
// http://tuxgraphics.org/~guido/javascript/base64-javascript.html
#define KEY "Your Key Here"
char twitterURL[] PROGMEM = "api.supertweet.net";
void sendToTwitter (byte tweetText)
{
uint8_t twitterip[4] = {66, 180, 175, 246};
ether.copyIp(ether.hisip, twitterip);
// generate the header with payload - note that the stash size is used,
// and that a "stash descriptor" is passed in as argument using "$H"
Stash::prepare(PSTR("POST /1.1/statuses/update.json HTTP/1.1" "\r\n"
"Host: $F" "\r\n"
"Authorization: Basic $F" "\r\n"
"User-Agent: Arduino EtherCard lib" "\r\n"
"Content-Length: $D" "\r\n"
"Content-Type: application/x-www-form-urlencoded" "\r\n"
"\r\n"
"$H"),
twitterURL, PSTR(KEY), stash.size(), tweetText);
// send the packet - this also releases all stash buffers once done
ether.tcpSend();
if (stash.freeCount() <= 3)
{
Stash::initMap(56);
}
#if DEBUG
Serial.print("Tweet, Sh: ");
Serial.println(stash.freeCount());
#endif
}