Simple Processing Twitter
I created a really simple Processing and Twitter sketch to help a friend a few nights ago ^_^ It is based off of this previous code from the blog post “Processing + Arduino + Twitter + OAuth”. Here’s what changed:
- It now uses the Access Token that you can get from the Twitter App’s panel
- No more inserting PIN info into a file
- No Arduino clutter in the sketch
- Simple methods for posting, retrieving, and searching tweets.
You can probably do a lot more things with this too, thanks to Twitter4j.
Or view it on Github
If you use this code in one of your projects, let me know! It is cool to see what people make.

This work is licensed under a Creative Commons Attribution 3.0 Unported License. GO OPEN SOURCE!



March 3rd, 2011 at 9:43 PM
I’m working on my final project and I was using the older version… your code is going to help me a lot, thanks for sharing; your name will be attributed.
March 6th, 2011 at 10:25 AM
This is GREAT! It works like a charm. Thanks so much!
March 14th, 2011 at 6:52 PM
thanks, this was super helpful
March 30th, 2011 at 1:21 PM
Thank you very much, this has solved so many problems.
However, the code is not returning any tweets from the search tweets section… is there something I need to do in order for it to return results?
March 31st, 2011 at 11:30 AM
great tutorial, but i’m having a small issue of locating the access tokens. all I get now is an “access token URL” and there is no longer a button, like you mentioned in your Processing code and that has been present in the past on the Twitter app settings page. How do I get the Token from the URL?
Thanks and awesome site!
March 31st, 2011 at 11:57 AM
Ignore that last comment. When i set up my App, it was at twitter.com/apps which has very little options.
dev.twitter.com/apps gets you to where you can locate the token information.
Still not getting it to work, as it’s throws an exception:
Send tweet: TwitterException{exceptionCode=[15bb6564-00e4d62e 15bb6564-00e4d603], statusCode=-1, retryAfter=0, rateLimitStatus=null, version=2.1.5-SNAPSHOT(build: d372a51b9b419cbd73d416474f4a855f3e889507)} Status code: -1
at least i’m moving in the right direction. i bet it’s an issue with my firewall.
thanks!
April 1st, 2011 at 10:36 PM
thanks! as usual u = win.
April 2nd, 2011 at 9:02 PM
THANK YOU ROBOT GRRL!!!!
Twitter4j is a fantastic library but it took your human-readable example for me to understand how to properly implement it. For a school project I had an idea for a Morse-Code-To-Twitter machine, also using the Morse Encoder Library for Arduino. My only challenge was figuring out how to collect the “chars” into strings, reading in processing, displaying messages and then sending to twitter. Thanks to all the time you saved me after killing almost an entire day trying to implement the 4J library, I had time left to create a backspace and handy “send to twitter” button right on my circuit board. Once I finish everything and clean up the code I’ll make it available so other people can join the #sentWithMorse twitter stream thanks to YOU!!!
you can see it finally operational here:
http://www.youtube.com/watch?v=4r8A4OWSvZQ&feature=player_profilepage
April 10th, 2011 at 2:33 PM
[...] some handy Processing code to facilitate Twitter access from within a sketch. It can be found at http://robotgrrl.com/blog/2011/02/21/simple-processing-twitter/. I have successfully used it to post a tweet to my personal account. This entry was posted in [...]
May 5th, 2011 at 1:18 PM
[...] tweets as an alternative to accessing the API via a web browser (as I did initially). I modified Robotgrrl’s Simple Twitter for Processing program to gather more tweets, limit them to English, and then write the username, date, and tweet [...]
May 28th, 2011 at 12:37 PM
Hello,
I would like to try your very interesting sketch.
I get a problem of a missing class:
“Cannot find a class or type named User”.
I put the twitter4j.jar file into Processing/libraries
I’m indeed missing some basic thing but at the moment I cannot really find a solution to the problem.
Any suggestion?
Thank you much for your amazing work!!!
√p
May 30th, 2011 at 9:35 PM
[...] Processing Twitter”, accessed May 25th, 2011, http://robotgrrl.com/blog/2011/02/21/simple-processing-twitter/ This code allows direct access to the Twitter API from within a Processing [...]
June 3rd, 2011 at 10:27 AM
Hey there,
Thanks a million for your code. It’s very easy to use and do things quickly.
One thing though: I’m listening to a hashtag by triggering a search for it every 5 seconds.
I take the first tweet in the list of tweets that’s returned and compare it to the previous “latest tweet”.
Not sure it’s the best way to go about this…
Anyway. The search doesn’t seem to be retrieving all tweets containing the hashtag (maybe only 1 out of 5).
Or are the returned tweets not in chronological order?
Anyone got an idea?
thanks again!
June 3rd, 2011 at 12:12 PM
OK, I figured out the problem.
Twitter has an algorithm that chooses the most relevant tweets and organises them in a list.
When doing a search on twitter, there are 3 kinds of lists of results available: top, all and with links.
With the current implementation of the code here, doing a search only returns the most relevant tweets (the “all” list).
Is there a way we could get the “top” list? i.e. every single tweet that comes out?
thanks!
July 20th, 2011 at 6:40 AM
Thanks for sharing that link but alas it seems to be down? Anybody have a mirror?
July 21st, 2011 at 9:29 AM
This is great, thanks so much!
By putting the twitter4j.jar file in a folder called “code” in my Processing sketch folder, this works great for searching tweets.
I can’t seem to post a tweet, however, but my application is listed as “read only” on Twitter’s dev site, so I assume this is the problem, not the Processing side.
Is there documentation for this library anywhere? Perhaps I have missed the obvious?
Thanks again, will share my documented project when it’s done
ao.
July 29th, 2011 at 10:19 PM
Hi thanks for posting this. Its nice to have a barebones example of Processing to Twitter. I’ve set up an application on Twitter and tried inputting my credentials into your code but I’m getting a Status code: 401 when I try to run your code. Have you or anyone else experienced the same problem? Thanks again.
July 30th, 2011 at 6:05 PM
Have to be careful about the Read-Only part! http://farm7.static.flickr.com/6149/5991617997_cd96913c77_b.jpg
That might be where the 401 error is coming from
The annoying thing though is that you have to make sure you change the permissions *before* generating your token. It seems as though there is no way to regenerate the token through the dev.twitter site after it was already generated -.-;
July 30th, 2011 at 8:20 PM
Yup that was the problem and you’re right that is annoying that you have to do it in that specific order. Thanks so much for the tip. I’m all set!
August 23rd, 2011 at 9:56 AM
hey there… worked like a charm. just had to comment out the User[] friends; bit.
Beware, world. I can send tweets from my processing apps.
October 21st, 2011 at 6:11 PM
I have tested to post a feed through processing and it worked!
Is there a way to view the latest feeds on the arduino lcd screen using this???
Is there an example code available on online?
February 23rd, 2012 at 12:40 AM
Thx for sharing this! I got it to work to post the given tweet to my Twitter account. I am new to Processing and wanted to see an example that would work right away. So this was perfect. But I noticed that you have one twitter4j.jar file but the Twitter4J site’s download consist of multiple jar files in different folders. Which one of them is the single jar file you are using?
February 29th, 2012 at 5:47 AM
Thank you so much for posting this. I REALLY appreciate!
March 6th, 2012 at 9:58 AM
Thank you for this. It’s hard to find a basic tutorial on this subject, let alone one that’s easy to understand for the beginner. This has given me a great starting point from which to build on. Bravo.
August 16th, 2012 at 4:24 PM
Hi,
can you briefly explain how to use the code? Sorry I am new to this.
thanks for your time and for the motivation, this made me go out and buy an Arduino, Ethernet sheild, and a couple other things. I just need a little help getting all of this to work, I am sure things will click soon.
best wishes,
Rob
October 12th, 2012 at 4:42 AM
Thanks but I have test your code for send tweet and It’s very good. But When I use twitter4j for send image with twitpic or other… it doesn’t work.
So I propose you an other library for processing: processing-http
https://github.com/francisli/processing-http/wiki
It’s so easy to build. You must try it!
Thank you!
December 2nd, 2012 at 10:15 AM
Hi RobotGrrl, Love your work; but must take so much time and effort! I tried Using our code( I got ConsumerKey And Secret, And i also Got the AccessToken And secret. I put them in the required Gaps And i got an error in the Arduino Coding enviroment saying ” expected unqualified-id before ‘private’ ” It also highlights the accessTokenSecret Line
(“static String AccessTokenSecret = “**************”;”) I’m Pretty new to the whole arduino thing and i have done basic coding before so im pretty stumped as to whats causing the problem and how to fix it. I understand that wher it says “Expected unqualified-id” There is something that it thinks should be there and that when it says “before ‘private’ ” I realise that it wants the ‘thing’ infront of ‘private’ but the thing is i don’t know what it is referring to. Any help would be appreciated immensely.
If anyone has a solution, you can email me at fraserhoenes@yahoo.co.uk.
Many Thanks,
A fellow coder
December 2nd, 2012 at 10:16 AM
*Your
December 29th, 2012 at 4:44 PM
[...] http://robotgrrl.com/blog/2011/02/21/simple-processing-twitter/ [...]
February 25th, 2013 at 9:26 PM
[...] The code could be tidier, but for now this is satisfactory.The twitter code we used came from robotgrrl.comA TL;DR of the code is as [...]
March 5th, 2013 at 3:39 PM
Thanks so much for posting this code!
I’ve got it half working. And it looks like its the opposite problem that others are having. I can tweet from inside Processing but can’t seem to grab the tweets from my feed (other than the posts from Processing).
I suspect it may be my settings from the “Request URI” and “Request query” areas in the Request Settings window in the Developers area. Anyone know if I’m on the right track for narrowing the problem down?
I’ll be sure to link to my video using this snippet when I’m done.
April 10th, 2013 at 12:38 PM
[...] on the same Processing code and Arduino hardware I’ve been tinkering with (many thanks to RobotGrrl and Ashley Hughes for some very helpful [...]
May 12th, 2013 at 1:44 PM
Hi,
Thanks so much for easy to read instructions, code and the sketch! so many others forget to even say simple things like “set up a developer account”
best of luck with your own projects!
May 12th, 2013 at 2:18 PM
[...] http://robotgrrl.com/blog/2011/02/21/simple-processing-twitter/comment-page-1/#comment-329527 [...]
May 21st, 2013 at 12:57 PM
@John, did you ever find a solution to this? I am having the same problem.
Great work by the way, best and easiest to understand example on the web
May 26th, 2013 at 10:52 PM
RobotGrrl thanks for the post… A few questions you might be able to help with or anyone else… What version of Twitter4J are you using for this? I can’t get it working on Twitter4J.3.0.3..
says… function setRpp(int) does not exist…
Changed it to count then
cannot find class or type named “Tweet”
Any idea?
Thanks in advance…