Pages: [1]   Go Down
Author Topic: Twitter and duplicate post fix?  (Read 470 times)
0 Members and 1 Guest are viewing this topic.
Nova Scotia
Offline Offline
Full Member
***
Karma: 4
Posts: 204
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


I have two way communication working on my Arduino with ethernet shield. Right now with each button press it tweets that a button has been press x many times, turn on LED? If a tweet a Yes the LED turns on and a No turns it off. If a Yes does not work then two duplicate posts in a row will not work.  A time stamp or random number after each Yes or No is possible but ugly. Is there another way?
I found the bit of code below that I am NOT currently using because i'm not sure what it does or if it is a possible fix for my problem. No idea what the "status == 200)" does.
 

if (twitter.post(buffer)) {
    int status = twitter.wait();
    if (status == 200) {
      Serial.println("OK.");
    } else {
      Serial.print("failed : code ");
      Serial.println(status);
    }
  } else {
    Serial.println("connection failed.");
  }
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 640
Posts: 50332
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
No idea what the "status == 200)" does.
Every HTTP transaction returns a status code. 200 is success in HTTP terms. This code is testing that the last post was successful. If so, it sends one message to the serial port. If not, it sends another.

It does nothing to ensure that the post WILL BE successful.

Quote
Right now with each button press it tweets that a button has been press x many times, turn on LED?
Why would anyone else in the world care?

Logged

Nova Scotia
Offline Offline
Full Member
***
Karma: 4
Posts: 204
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Each twitter post is set up to text my cell phone so I use it now as a remote monitor with the ability to turn on and off I/O pins with my cell. No one cares to read these twitter posts but me. It could be connected to a motion sensor with the ability to turn on an alarm, monitor the temperature of something with the ability to remotely shut it down if it gets too hot. Many possibilities...
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 640
Posts: 50332
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Many possibilities...
Sure there are. But 99.999% of them are of interest to you, and only you. That is not what Twitter is for. If you expect to abuse a free service, you need to play by their rules.

Otherwise, spend the $10 a month for your own web site that you can post freely to.
Logged

Gosport, UK
Offline Offline
Faraday Member
**
Karma: 21
Posts: 3113
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

To be fair, it's probably as interesting as anything else on Twitter.
Logged

Pages: [1]   Go Up
Jump to: