Following Tweets!!
in
Contributed Library Questions
•
1 year ago
Hello forum!
First post here, I was wondering how I can access the timeline data and fill my ArrayList with each post send by a single and specific user.
For example, I want to track sequentially all the posts that are sent from a specific user (i.e. @CNN), and keep the posts organized in an ArrayList - that is printed in my screen.
Please have a look at the following attempt I am trying at the moment from bits I have found around. The problem with the code is that it does not give me the sequenced results, rather spits various posts from the user.
Thanks!
- /* OpenProcessing Tweak of *@*http://www.openprocessing.org/sketch/24740*@* */
- /* !do not delete the line above, required for linking your tweak if you re-upload */
- Twitter myTwitter;
- void setup() {
- myTwitter = new TwitterFactory().getInstance();
- size(500,300);
- frameRate(30);
- background(255);
- noStroke();
- smooth();
- textFont(createFont("SansSerif",11));
- textAlign(LEFT);
- }
- int count1;
- String racer1 = "CNN";
- void draw() {
- try {
- Query query1 = new Query(racer1);
- QueryResult result1 = myTwitter.search(query1);
- ArrayList tweets1 = (ArrayList) result1.getTweets();
- for (int i = 0; i < tweets1.size(); i++) {
- Tweet t = (Tweet) tweets1.get(i);
- String msg = t.getText();
- String user = t.getFromUser();
- fill(255);
- rect(0,0,width,height);
- fill(0,0,240);
- text("#" +racer1 +"(" +user +")", 10, 20);
- //The following code is for the "Red Box"
- fill(0);
- text(msg,10,25,350,590);
- noStroke();
- println (i);
- }
- }
- catch (TwitterException te) {
- println("Couldn't connect: " + te);
- }
- }
1