... replacing with your callback url, i.e. the URL of the page in your application that twitter will redirect the user back to, after they have authorised your application to access their account. In this example, it's the url of the action in the next step. (Note, when you register your app, if you are developing locally, and you tried to enter your callback url with localhost in it, twitter might grumble. A little gem I read somewhere said you can actually create a bit.ly link, add your local callback URL in there, and then add the bit.ly link as the call back url in the twitter application settings. I still add my localhost url in this place though).

This action fetches a request token from twitter, which it then adds as a query string param to the authorize URL on twitter.com that the user is redirected that prompts them to authorise your app.

After the user authorises your app, twitter redirects them back to this action, the callback you specified in the previous request. In the querystring are 2 params called 'oauth_token' and 'oauth_verifier'. These, and the consumer key and secret are then sent back to twitter, this time requesting an access token.

At the end of this action, $response contains an associative array with keys for: 'oauth_token', 'oauth_token_secret', 'user_id', 'screen_name'. You should save 'oauth_token' and 'oauth_token_secret' to the session or the database as you need them when you want to access the Twitter API. Then redirect the user to another action, or display a thanks message or tweet to their account or whatever.

Now if you link to the twitter_connect() action or hit it in your browser address bar, you should be directed off to twitter to authorise your application, and once done, be back within your app with some twitter accounts access tokens.

Finally, I guess it's useful to know how to do something with the twitter API with this new found power: