Made my own TwitterClient and I think it's better than the example one

bump

When I past this in my browser:

http://api.twitter.com/1/statuses/user_timeline.rss?screen_name=JO3RI&count=1%20HTTP/1.1

replace JO3RI with your own twitter name if you like.

and if I try the same thing with hashtag search,

http://search.twitter.com/search.atom?q=%23arduino

I still get to see the last tweets, so mine is still working

yup mine is working too but when you use a code on Arduino IDE that uses GET HTTP, it doesn't seem to get tweets off twitter with that exact same line. any ideas?

also is there a way to implement oauth without going thru a PHP server?

I would give Arduino IDE 1.0 a try, the newer version seems to have other issues with my code (like dns)

i'm on arduino IDE 1.0! tested your code a while back. i could receive a weather update via xml but can't receive tweet updates via the same thing.

And you didn't change a thing? That's strange indeed. I could test your code on my own Arduino and network if you'd like.

Just attach your code to a reply and I'll give it a try. If it works on my end, you might have network issues. OR you might have set the interval to low so your Arduino is asking for updates way to fast and your IP got banned.

Could you please help me to fix it? Do you have any idea of how I can solve it? Could your code help me to do it?
You'd be very helpful, really

are you able to show those characters on the serial monitor, when put into a string? (not from twitter, but when you just do Serial.print("those special characters"); ?

You can replace those &#241 , &#191, &#161 with the actual character. I did that in another project of mine (www.jo3ri.be/arduino/projects/castduino). You can start looking for &# with Textfinder and when found replace those with along with the according number.

Something like if &# and 241 than you have ñ.

also check google on "string replace" (http://www.cplusplus.com/reference/string/string/replace/)

Nice work and thanks for sharing!

I have been playing with a similar idea for control purposes, but never actually built any of it.

A trick I find could help a lot to simplify the on-board Arduino logic would be to put a service in-between the Arduino and the Twitter API to act as a proxy and format translator.

The idea would be that you can use the right tool for the right job. Calling a REST webservice, parsing the results and doing something with the data is a piece of cake in most "internet languages", like Java, JavaScript, Ruby or PHP. With a such a proxy in place, you could re-format the response from Twitter into something very Arduino-friendly to save valuable CPU and RAM. It would also give you a separation of concerns and provide a place to add more advanced features like caching of results and adding in more sources without having to change the Arduino program.

Hosting of the translator proxy could be done on a server of yours, or on an application hosting service like the examples below.

or http://nodejitsu.com/

Anders

Nice work and thanks for sharing!

Thanks :wink:

The idea would be that you can use the right tool for the right job.

Good point, but sometimes it's just fun to have all in one solutions.

Good point, but sometimes it's just fun to have all in one solutions.

That is true and fun is one of the most important factors to consider. Why else would one have an Arduino hobby?

Why else would one have an Arduino hobby?

If you really want to know ask this in the bar sport section :wink:

hi JO3RI, many thanks for the work!

Just testing it out and it only seems to return one tweet? I am pulling tweets from https://twitter.com/BBCBreaking to return latest news items but it only returns the latest, and after that it just keeps looking but not returning tweets?

Maybe I misunderstand something, but I have tried it with other usernames and it seems the same?

Is there also a way to display my twitter feed (to display tweets from those I'm following)?

Again, thanks :slight_smile:

dtokez:
Is there also a way to display my twitter feed (to display tweets from those I'm following)?

What you are looking for is the Home Timline
https://dev.twitter.com/docs/api/1/get/statuses/home_timeline

The way I have set-up this client, it only shows the last tweet, it does 't get pushed on every new tweet. It just checks the time-line every x seconds and shows that tweet.

Hope that answers your question.

What I did was this:

byte b = 0;
for (byte i = 0 ; i < 81 ; i++){   //this buffer is only 80 characters
  byte txt1 = buffer[i + b];      //look at the first character
  byte txt2 = buffer[i + b + 1]; //look at the second character
  byte txt3 = buffer[i + b + 2]; //look at the third character
  // lets make some of those special html characters readable
  if (txt1 == '%')
  // if you find an %, we will start looking for de second and tirth character
  // than we recalculate those into a new char en replace txt1 with the new one
  {
    char ascii[17] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
    for (byte c = 2; c < 8; c++){
      for (byte d = 0; d < 17; d++){
        if (txt2 == ascii[c] && txt3 == ascii[d]){
          txt1 = 32 + (((c-2)*16)+d);  //recalculate 2 separate HEX to one new
          b= b + 2; // go the the next character and therefore skip 2
        }
      }
    }
  }
}

But you will not be able to use it as is (it only replaces 2 HEX characters into 1 new)

To help you further, post me your twitter buffer (tweet) as you get it on your console. Second I need to know if in your buffer (tweet) this "&#241" takes 5 places or 3. Because we need to know if 241 is one character or three (2,4,1). if it is three, you'll have to do something like this:

txt1 = (txt3*100) + (txt4*10) +txt5)

it might be as simple as to look for:

if (txt1 == '&') && (txt2 =='#')
{
  txt1 = (txt3*100) + (txt4*10) +txt5)
}

and do this for all characters in your buffer (see first code in this post) and combine (don't forget to skip 4 places instead of 2, and don't forget your tweet buffer is 140 not 80, and you'll probable need txt1 till txt5)

On the other hand you could use textfinder on your "tweet" buffer and look for &#241 and replace it with '241' (1 character)

oh, and could you post the twitter account that posts those funny Spanish characters?

Because this a Gallery topic, It will be better to ask your question in an other Forum part. Just ask your question in the Programming Questions.

How to convert this:

char tweet[]="Probando la &#241; la &#191; y la &#161; por ejemplo.";

into this:

char tweet[]="Probando la ñ la ¿ y la ¡ por ejemplo.";

Put a link to your question here.

Please don't keep asking your questions here, make a new topic

JO3RI:
The way I have set-up this client, it only shows the last tweet, it does 't get pushed on every new tweet. It just checks the time-line every x seconds and shows that tweet.

Hope that answers your question.

Hi JO3RI, thanks for explaining that to me. is there a way to change the behaviour to show say the 10 latest tweets, and to update if a new one is posted?

Thanks for all your efforts!

Hi JO3RI, thanks for explaining that to me. is there a way to change the behaviour to show say the 10 latest tweets, and to update if a new one is posted?

Well, If you that every tweet would have to be placed into a buffer in SRAM and every buffer is 140 bytes x 10 times is 1400 bytes only for those tweetbuffers (you only have 2048) and you need some for the libraries too.

You could use only 1 buffer and flow 10 tweets through it, but than you can't compare if it is a new tweet or not. To check if a new tweet is posted, I think you can only check periodically and compare the tweets you have, with the once you just checked.

This Arduino Client just asks the tweet stream, gets all of it and starts looking for the last tweet (the top) one, every 60 seconds.
try this in the url of your browser for a tweet account:

https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=JO3RI&count=1%20HTTP/1.1

and this for a hashtag:

http://search.twitter.com/search.atom?q=%23arduino

you'll see you have to refresh your browser to get an update

Maybe now you'll understand the problems to overcome. If you are going to try this, please ask your questions in the programming section, splitting your problem into small problems and try to tackle one at a time.

Have fun

With the requirement from Twitter to use their new api, this code does not work - returns the error page.

Does anyone have updated code that can used with the new Twitter api?