3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Give Your Cat Twitter Powers

Step 6Send a Twitter update

Sending a Twitter update is very easy with the help of the Twitter4j library.
Here's the minimum code to post a status update from Processing. You'll have to add the twitter4j jar file that you downloaded earlier to your Processing sketch though the Sketch->Add File menu.

// Send a status update to Twitter via the twitter4j API// You have to add the twitter4j-x.x.x.jar file to your sketch via Sketch->Add FileString twitterID = "XXX"; //your twitter IDString twitterPassword = "XXX"; //your twitter passwordvoid setup(){}void draw(){  //send new tweet on mouse click  if(mousePressed) {    sendTweet("Updating my status from Processing.");  }}// Send the tweet passed in as String argumentvoid sendTweet(String msg) {    //construct a new twitter object    Twitter twitter = new Twitter(twitterID,twitterPassword);      try {      Status status = twitter.update(msg);      System.out.println("Updated the status to [" + status.getText() + "].");    } catch (Exception e) {      e.printStackTrace();    }}

To make the updates more interesting, you'll probably want a whole set of alternative status messages that you can switch between. Take into account whether your cat is on or off the bed. How long she's been there. What time of day it is. Etc...
« Previous StepDownload PDFView All StepsNext Step »
1 comment
May 3, 2009. 9:33 PMRazorConcepts says:
I get an error: "The constructor Twitter(String,String) is undefined" Any ideas? The jar file is in the code directory. Thanks!

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
6
Followers
2
Author:bpunkt