I've run into a strange problem involving trying to integrate the thingsTweet app into my program. The arduino basic example seems to work well when using one analoge input to update a graph.
I tried adding the updateTwitterStatus function into the mix (yes I've defined the thingsTweet api variable) and it consistently gives me a 400 bad request. I'm not even calling the function yet from the loop. Simply having the function in my sketch causes the 400 bad request. The sketch compiles fine with no errors. Here's the function:
void updateTwitterStatus(String msg)
{
if (client.connect() && msg.length() > 0) { // Create HTTP POST Data
msg = "api_key="+thingtweetAPIKey+"&status="+msg; Serial.println("Connected to ThingTweet..."); Serial.println(); client.print("POST /apps/thingtweet/1/statuses/update HTTP/1.1\n"); client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("Content-Type: application/x-www-form-urlencoded\n"); client.print("Content-Length: ");
client.print(msg.length());
client.print("\n\n");
client.print(msg);
} else {
Serial.println("Connection Failed.");
Serial.println();
}
}
While trying to debug this problem I removed the client.print commands from this function but left everything else in and then the sketch started working properly. If I left even just one line of client.print in the updateTwitterStatus function the sketch fails. I also tried creating a new instance of client called clientTwitter leaving client for the updateThingSpeak function. Still caused problems.
I'm kind of stumped here. Is this an arduino ethernet library bug or is it a thingspeak problem?
This does not solve the imediat issue, but you can post and Tweet at the same time if you want.
example: field1=6&twitter=(twitter username linked with ThingTweet)&tweet=(your tweet)
You would only want to do this occasionally and not with every insert to your ThingSpeak channel. Twitter would rate limit you.
We will check into the other sketch. Can you send us the PDE your using? support@thingspeak.com
I have written a new Arduino sketch that combines the Thing Channel update and ThingTweet sketch into one.
You can download it here: http://bit.ly/nFrpUE
Try this and see if this works for you and your situation.
Most Users Ever Online: 166
Currently Online:
26 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
rw950431: 272
Vinod: 240
piajola: 95
turgo: 70
vespapierre: 63
Adarsh_Murthy: 62
Member Stats:
Guest Posters: 1
Members: 8665
Moderators: 1
Admins: 2
Forum Stats:
Groups: 3
Forums: 14
Topics: 1600
Posts: 5760
Newest Members:
Advantagetreeexperts, laundrydaddyuk, techhhelp5, ken, tran, huldacormierModerators: cstapels: 460
Administrators: Hans: 405, lee: 457