Go Down

Topic: Made my own TwitterClient and I think it's better than the example one (Read 15484 times) previous topic - next topic

Anders 2009


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

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.
http://www.JO3RI.be

Nederlandstalige sectie - http://arduino.cc/forum/index.php/board,77.0.html -

JO3RI

What I did was this:
Code: [Select]

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:

Code: [Select]
txt1 = (txt3*100) + (txt4*10) +txt5)

it might be as simple as to look for:
Code: [Select]
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?
http://www.JO3RI.be

Nederlandstalige sectie - http://arduino.cc/forum/index.php/board,77.0.html -

JO3RI

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:
Code: [Select]
char tweet[]="Probando la &#241; la &#191; y la &#161; por ejemplo.";
into this:
Code: [Select]
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
http://www.JO3RI.be

Nederlandstalige sectie - http://arduino.cc/forum/index.php/board,77.0.html -

dtokez


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!

JO3RI

Quote
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
http://www.JO3RI.be

Nederlandstalige sectie - http://arduino.cc/forum/index.php/board,77.0.html -

skeinath

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?

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy