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 ... 6
Processing and Twitter (Read 65233 times)
Processing and Twitter
Oct 18th, 2007, 8:41pm
 
Hi

Has somebody done a processing program using the twitter's api ?

if(key=='1'){
     background(255);
     twitter= new PClient(this,"http://www.twitter.com",80);
     requete_twitter = twitter.POST("http://login:pass@twitter.com:80/statuses/update.xml",var2,val2);
     requete_twitter = twitter.GET("http://assets1.twitter.com/javascripts/prototype.js?1192587430");
     requete_twitter = twitter.POST("http://twitter.com/statuses/update.xml",var2,val2);
     noLoop();
   }

this don't work... I don't know why !
Re: Processing and Twitter
Reply #1 - Oct 19th, 2007, 2:00pm
 
please use the mobile board for questions about mobile processing.
Re: Processing and Twitter
Reply #2 - Nov 13th, 2007, 5:45pm
 
I need this information too.
Today I can load rss feeds, but i need twitter support too.
Re: Processing and Twitter
Reply #3 - Dec 8th, 2007, 5:14pm
 
i am actually working on a Twitter application using Processing/Java, and I am using the Twitter4J library (http://yusuke.homeip.net/twitter4j/en/index.html) and it works really well... solid and complete.

i might as well plug my project here too Smiley
http://silentlycrashing.net/tweetpad
Re: Processing and Twitter
Reply #4 - May 11th, 2008, 8:01pm
 
Thanks for posting your stuff prisonerjohn! TweetPad looks cool. The Twitter4J library was just what I needed for my own little project.
Re: Processing and Twitter
Reply #5 - May 12th, 2008, 7:42pm
 
Well I have been playing around with Twitter4J a little, but got stuck pretty quickly. Here's what I have so far:

Code:
 
Twitter twitter;
int friendCount;
User[] friends;

twitter = new Twitter("myusername","mypassword");

try {
friendCount = twitter.getFriends().size();
friends = new User[friendCount];

for (int i = 0; i < friendCount; i++) {
friends[i] = twitter.getFriends().get(i);
}
}
catch (TwitterException e) {
println(e.getStatusCode());
}


Which does not run. In stead I get:

Quote:
/tmp/build30734.tmp/Temporary_4468_9865.java:12:5:12:44: Semantic Error: The type of the right sub-expression, "java.lang.Object", is not assignable to the variable, of type "twitter4j.User".


Anyone have an idea what's going on? The Twitter4J JAR is in my code folder.
Re: Processing and Twitter
Reply #6 - May 12th, 2008, 9:52pm
 
Hi Kars,

Twitter.getFriends() returns a List of Users (List<User>) but this parametrization (is that a word?) is not available in Processing, since it's running in Java 1.4 and not 1.5+

Try this instead
Code:

...
for (int i = 0; i < friendCount; i++) {
friends[i] = (User)twitter.getFriends().get(i);
}
...

to tell Processing that the Object returned by List.get() is a User.
Re: Processing and Twitter
Reply #7 - May 12th, 2008, 10:35pm
 
Wonderful Elie, that's working like a charm. I figured it had something to do with that List interface, but couldn't figure it out. Thanks a lot!
Re: Processing and Twitter
Reply #8 - Oct 8th, 2008, 9:25pm
 
Can someone help me with twitter4j?

When using the methods like: twitter.getFriendsTimeline() or  twitter.getFriends()

the results that i retrive are something like this(for the statuses using getFriendsTimeline()): twitter4j.Status@362a63...

Can someone help me understanding this data? .. how can i retrieve user's "names" and their updates?

thanx
Re: Processing and Twitter
Reply #9 - Oct 10th, 2008, 3:01pm
 
You should look, if not already done, at the library's API doc: http://yusuke.homeip.net/twitter4j/en/javadoc/index.html

getFriends returns a list of User objects, getFriendsTimeline returns a list of Status objects.
Apparently these objects have no toString implemented, so when you print them, you get a generic Java answer showing the class name and some ID of the instance you look at.

If you have a status object, you can print status.getCreatedAt() and status.getText() to have some info.
If you have a user object, you can print user.getName() and user.getDescription(), among other things.
Look at Status and User pages of the above doc. for more.
Re: Processing and Twitter
Reply #10 - Oct 10th, 2008, 3:46pm
 
Thanx for all the help. Kars already showed me how to access the data. I'm currently retrieving all that i want Wink.

Thanx all
Re: Processing and Twitter
Reply #11 - Jan 27th, 2009, 9:13pm
 
Any one of you could explain to me how to install Twitter4j because this library is not written for processing and there is no directory named 'Librairie'.

Thanks,
Johnny
Re: Processing and Twitter
Reply #12 - Jan 28th, 2009, 5:07pm
 
Drag the .jar file onto your sketch window. It should be added to the code folder of that sketch. That's it, you're good to go.
Re: Processing and Twitter
Reply #13 - Mar 22nd, 2009, 12:05am
 
Hello, Trying to get up and running with twitter and processing. I am trying to run the hello world program

Twitter twitter;
int friendCount;
User[] friends;


twitter = new Twitter("twitterid","twitterpswd");
Status status1 = twitter.update("hello");

and it give me an Unhandled exception type TwitterException

No idea whats going on??
Re: Processing and Twitter
Reply #14 - Mar 22nd, 2009, 12:42am
 
Unhandled exception means a method call might throw an exception, if something wrong can happen: lot of bad things can happen on network access!

Look at Reply #5, Kars surrounds the call with a try/catch.
Pages: 1 2 3 ... 6