If you are the owner of a Twitter "App" that you've registered, and all
you want to do, for example, is post an update programmatically to your own account, you can get all the tokens you need by simply logging in at dev.twitter.com under
that account.
Click on the "Your Apps" link at the top, and then click on the application
you want to use programatically.
What you need are the ConsumerKey and the ConsumerSecret, and then if you click on
"My Access Token" at the right, you will need the Access Token, and
the Access Token Secret.
With these four strings stored in your <appSettings... section, you are ready
to roll -- and OAuth callbacks etc. are no longer needed.
The OAuth token, PIN and callback redirect scenarios are only needed if you want
to be able to have a user authorize your application on their behalf.
Here is some easy sample code that posts a Twitter update on your account using the
Twitterizer library:
OAuthTokens tokens = new OAuthTokens();
tokens.ConsumerKey = ConfigurationManager.AppSettings["ConsumerKey"];
tokens.ConsumerSecret = ConfigurationManager.AppSettings["ConsumerSecret"];
tokens.AccessToken = ConfigurationManager.AppSettings["AccessToken"];
tokens.AccessTokenSecret = ConfigurationManager.AppSettings["AccessTokenSecret"];
StatusUpdateOptions options = new StatusUpdateOptions();
TwitterStatus newStatus = TwitterStatus.Update(tokens, message, options).ResponseObject;
-That's all it takes! Of course, your code will need to have a reference to and a
using statement for the Twitterizer (Twitterizer2.dll) assembly. As with any
Tweet, you'll need to include your own short url, along with any RT or other
key Tweet Tokens you need, and it all must fit into 140 characters in the message
variable.
You can find the Twitterizer Google Code repository here.