We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › Twitter, Processing and Twitter 4J. Again
Page Index Toggle Pages: 1
Twitter, Processing and Twitter 4J. Again (Read 1619 times)
Twitter, Processing and Twitter 4J. Again
Jul 30th, 2009, 1:54pm
 
I´ve been trying to use the Twitter 4J library and Processing to do search queries. The example on the Twitter4J website, under sample code, goes like this:



   Twitter twitter = new Twitter();
   Query query = new Query("source:twitter4j yusukey");
   QueryResult result = twitter.search(query);
   System.out.println("hits:" + result.getTotal());
   for (Tweet tweet : result.getTweets()) {
       System.out.println(tweet.getFromUser() + ":" + tweet.getText());
   }




This does not run because of an error in the for loop. To be more specific, this part:

for (Tweet tweet : result.getTweets()) {
       System.out.println(tweet.getFromUser() + ":" + tweet.getText());







I´ve made some adjustments and can get it to print out all the info from the query:


Twitter twitter = new Twitter();
   Query query = new Query("design");
   try {
   QueryResult result = twitter.search(query);
 
   for (int var = 0; var < 1; var++) {
       System.out.println(result.getTweets());

   }
   }
 
      catch( TwitterException e)
       {
            println(e.getStatusCode());
       }





The problems is that I want to now use the Tweet Class to implement some methods which will pull out specific information from the query, such as the text of the update and the user id. Frankly speaking I just don´t know how to create a Tweet object and connect it to the query. I think it has to do with not knowing how to properly use the constructor.

Any help?








Re: Twitter, Processing and Twitter 4J. Again
Reply #1 - Jul 30th, 2009, 2:33pm
 
alot of twitter questions are answered here. maybe its something for you too:
http://processing.org/discourse/yabb2/num_1192732862.html
Re: Twitter, Processing and Twitter 4J. Again
Reply #2 - Aug 2nd, 2009, 3:30pm
 
Thanks for link Cedric, but I´ve actually scoured that post pretty good.

I´m surprised that there aren´t more people using this library.

When I finally get my project done, I´ll be posting it.

Re: Twitter, Processing and Twitter 4J. Again
Reply #3 - Aug 2nd, 2009, 3:36pm
 
that would be nice to see
Page Index Toggle Pages: 1