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 & HelpIntegration › Processing and Twitter
Pages: 1 2 3 4 5 6 
Processing and Twitter (Read 65234 times)
Re: Processing and Twitter
Reply #45 - May 1st, 2009, 2:27am
 
I think it is not a problem of scope, which is fine here, but of order of events.
If I read correctly, you instanciate the Twitter class with username and password variables before they are set/read, so with null values.
Re: Processing and Twitter
Reply #46 - Jun 24th, 2009, 11:00am
 
Does anybody of you have an working example  that uses the twitter search and saves the results/tweets for a special predefined searchword  as different Strings?
Re: Processing and Twitter
Reply #47 - Jun 25th, 2009, 1:47am
 
Hmm, im still trying to get a simple example to work. i tried out some of the examples posted here, and i get the same problems, "type status is ambigious" etc. etc. but none of them works. does anybody have a real basic, programm to just test it? Did I install it right? I copied the twitter4j-2.0.8.jar and all the other jars that were in the lib folder to the sketch code folder.
THX!
Re: Processing and Twitter
Reply #48 - Jun 25th, 2009, 2:17am
 
cedric,

the ambiguous error tells you it doesnt know which type it is. in this case i believe it is a List.

declare as:
java.util.List status;

yes you installed it right.. just need a copy to the libraries folder
Re: Processing and Twitter
Reply #49 - Jun 25th, 2009, 2:33am
 
I read about this in this threat and a lot of people solved it. This is the whole code of one example that seems to work when used by others.
It still tells me "The type Status is Ambigious"

Could you maybe specify where i have to change something?
Thank you!

Code:
Twitter twitter;
String myTimeline;
User[] friends;
String username = "USERNAME"; // add your own here
String password = "PASSWORD"; // add your own here
java.util.List statuses = null;

twitter = new Twitter(username,password);
//java.util.List statuses = twitter.getUserTimeline();
try
{
statuses = twitter.getUserTimeline();
}
catch( TwitterException e)
{
println(e.getStatusCode());
}
for( int i=0; i<statuses.size(); i++ )
{
  Status status = (Status)statuses.get(i);
  println(status.getUser().getName() + ":" + status.getText());
}
Re: Processing and Twitter
Reply #50 - Jun 25th, 2009, 2:39am
 
rename the jar file to the same name of your folder..

try folder name "twitter4j" and libname "twitter4j.jar"


im just telling you what i did when i tried it.. and your code compiles just fine here too..

that must be something about java ? are u using expert version of processing? just throwing out ideas, not sure whats going on
Re: Processing and Twitter
Reply #51 - Jun 25th, 2009, 3:02am
 
Alright i got it.
My fault was that i copied not only the twitter4j-2.0.8.jar but also the jadadoc jar and source jar that comes with the zip file .

Thanks for your help!
Re: Processing and Twitter
Reply #52 - Jun 25th, 2009, 3:04am
 
you're welcome
Re: Processing and Twitter
Reply #53 - Jun 25th, 2009, 3:16am
 
sorry to bother you again, now as it is working, i try to use what i was looking for. a simple query search. But im having a hard time converting this :

You can search for Tweets using Query class and Twitter.search(twitter4j.Query) method as following:

   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());
   }



to processing code. Could you give me a hand on this? Would be great.
Re: Processing and Twitter
Reply #54 - Jun 25th, 2009, 3:19am
 
actually already did it at another post:

http://processing.org/discourse/yabb2/num_1245743072.html

its about the java syntax.. processing still doesnt work with foreach loops.
Re: Processing and Twitter
Reply #55 - Jun 25th, 2009, 3:44am
 
Thanks, that seems to work but i get stragnge results.

for example searching for ccc gives me only 1 result 6 days old...
using the twitter search : http://search.twitter.com/search?q=ccc
i get much more.

Also my hit counter always prints -1. so maybe there is an error somewhere?


As soon as i get on your nerves, let me know Smiley

Code:
Twitter twitter;
String myTimeline;
User[] friends;
String username = "UN"; // add your own here
String password = "PW"; // add your own here
//java.util.List result = null;




twitter = new Twitter(username,password);

//java.util.List statuses = twitter.getUserTimeline();
try
{
Query query = new Query("source:twitter4j ccc");
QueryResult result = twitter.search( query );
System.out.println("hits:" + result.getTotal());

java.util.List tweets = result.getTweets();
for( int i=0; i<tweets.size(); i++ )
{
Tweet tweet = (Tweet)tweets.get( i );
System.out.println(tweet.getFromUser() + ":" + tweet.getText());
}
} catch (TwitterException te) {
System.out.println("Failed to get queries: " + te.getMessage());
System.exit( -1);
}
Re: Processing and Twitter
Reply #56 - Jun 25th, 2009, 4:01am
 
hmm well the thing is in the query string..

you have "source:twitter4j ccc"

if you look at the results you will see from which client they tweet.

the source gives u results from the source.. so maybe no one is using twitter4j to post..

try :

"source:web ccc"

it will give you all results from tweets created on web..

you will need to find a way to search for all sources and sort them out.. or check the API to see how to do searches like the website.

or madly, just get a list of sources yourself and search them all, sort the results and show them =)

EDIT: i've just tested that, so don't take it for granted.. make some research, i might be wrong.
Re: Processing and Twitter
Reply #57 - Jun 25th, 2009, 4:09am
 
im an idiot Smiley i didnt realize, that source:twitter4j limits it to messages posted from t4j. i thought it just has to be there as it is part of the library...just deleting the source part and just writing    Query query = new Query("ccc"); does a good job, looks the same as the twitter web search. i still get a hits:-1 result but i hope that wont be a problem.
Re: Processing and Twitter
Reply #58 - Jun 25th, 2009, 4:10am
 
sometimes one doesn't see the easy way..

just pass the string with "ccc".

that might give better results and no filtering..


EDIT: you got it =)
Re: Processing and Twitter
Reply #59 - Jun 25th, 2009, 4:12am
 
here's the reason for the hits: -1


http://yusuke.homeip.net/twitter4j/en/javadoc/twitter4j/QueryResult.html


"int getTotal()
Deprecated. The Twitter API doesn't return total anymore"
Pages: 1 2 3 4 5 6