Go Down

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

dtokez

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 :)

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.

elHombreGer


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/)


Thanks for reply so fast JO3RI.
Well, I've opened a new sketch just to test this character (ñ):
Code: [Select]
char inChar1 = 'ñ';
char inChar2[] = {'ñ'};
char inChar3[] = "ñ";
char inChar4 = 241;
String inString = "ñ";

void setup()
{
  Serial.begin(9600);
 
  Serial.println("ñ");
  Serial.println(char(241));
  Serial.println(inChar1);
  Serial.println(inChar2);
  Serial.println(inChar3);
  Serial.println(inChar4);
  Serial.println(inString);
}

void loop()
{
}


Results:
Serial.println("ñ");  prints  ñ
Serial.println(char(241));  prints  ñ
char inChar1 = 'ñ';         Serial.println(inChar1);  prints  ±
char inChar2[] = {'ñ'};   Serial.println(inChar2);   prints  ±Ã±
char inChar3[] = "ñ";     Serial.println(inChar3);  prints  ñ
char inChar4 = 241;       Serial.println(inChar4);  prints  ñ
String inString1 = "ñ";     Serial.println(inString1);  prints  ñ
String inString2 = String(char(241));   Serial.println(inString2);  prints  ñ

I understand all of your code and it works, and I assure you I've been testing for days how to implement the replacement of those html characters and everything I'm testing doesn't work. Please, could you give me a hand and be a bit more explicit? This is the project for my degree ;) Thanks.

PD: I changed the format from .rss to .xml and obviously the strings StartHere, EndHere, etc...

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?

Go Up