To post a tweet, do the following:



* Install twitter4j http://twitter4j.org/en/index.html#download

* (Update: I've attached "twitter4j.jar" to this instructable page.)

* Create a Twitter account twitter.com

* Register an application with Twitter https://dev.twitter.com/apps/new



Install twitter4j



You'll need to install the twitter4j library so it can be used by Processing.

Get it here: http://twitter4j.org/en/index.html#download

Install it here (or equivalent): C:\Program Files\processing-1.5.1\modes\java\libraries

You're done.

Access it here: Processing > Sketch > Import Library... > twitter4j

And when you do, it'll add this to the top of your code:

import twitter4j.conf.*;

import twitter4j.internal.async.*;

import twitter4j.internal.org.json.*;

import twitter4j.internal.logging.*;

import twitter4j.http.*;

import twitter4j.api.*;

import twitter4j.util.*;

import twitter4j.internal.http.*;

import twitter4j.*;

Incidentally, you'll also add Serial I/O from the Sketch > Library, but that's not important right now.



So why do you need twitter4j? The short answer is that it provides you with simple functionality so you don't have to write a whole bunch of crazy code every time you want to access Twitter. We use twitter4j because it's awesome and it makes our job easier.



Create a Twitter account



You've probably already got one (or twelve) but for the absolute noob, take heart. It's easy.

Goto twitter.com and set up an account. Make it a public account, that way if you ever want your friends to look at it they don't have to go through a whole bunch of hooey to get there. And don't post personal stuff like "Out of town, leaving diamonds on back porch."



You'll see people using the "@" and "#" symbols a lot. Put @ before a username and # before a concept. For example, if you post the following tweet "I enjoyed the @msg_box simpleTweet_00 on @instructables #goodtimes" then that tweet will get sent to my feed (and to instructables's feed too) and it'll get added to a cache of all posts that have ever used the phrase "#goodtimes." There's more, but it's not within the scope of this lesson. Play with it. You'll figure it out.



Register an application with Twitter



What does that even mean? Relax. Think of it this way: you're creating a set of special high-tech usernames and passwords so the stuff you make can access Twitter. It's like Twitter is this big castle with a front door for all the human guests and a back door for all the automated service personnel. These high-tech usernames and passwords are called OAuth. OAuth lets your device access Twitter through the service entrance.



Having already created my Twitter account @msg_box I then went here https://dev.twitter.com/apps/new to get my OAuth password info. Review the three attached images of the forms .



First Page: Make sure you check "Client " and not "Browser", and that you allow "Read & Write ."

Second Page: Here's where you find your CONSUMER KEY and your CONSUMER SECRET

Third Page: Here's where you find your ACCESS TOKEN and your ACCESS TOKEN SECRET



You will need this information when your program logs into Twitter (via the service entrance.) In the Processing script simpleTweet_00_p you will enter this information in here:

static String OAuthConsumerKey = "YOUR CONSUMER KEY";

static String OAuthConsumerSecret = "YOUR CONSUMER SECRET";

static String AccessToken = "YOUR ACCESS TOKEN";

static String AccessTokenSecret = "YOUR ACCESS TOKEN SECRET";



That's it. Not hard at all.





