Category Archives: Air and Flex

Information, examples and more on Adobe Air/Flex

twitcher update coming soon…

Now I have repaired my laptop (the graphics card died again … third one this year) I will be able to start working on more changes to twitcher.

Firstly, I hope to be pushing an update shortly that allows JSON powered Short URL services like and to use the ShortURL plugin system in twitcher. This will allow most types of short url to be added easily using a simple XML configuration file.

Secondly, after using the great ReadItLater site (see my earlier blog post) I would quite like to integrate this into twitcher in some form.

Lastly, I would hope to add some simple form of syncronisation as it really annoys me when I have twitcher at home and work and I have to keep skipping past the tweets I have already seen in one of the other locations.

If you have any suggestions then do get in touch.

Post to Delicious Post to Facebook Post to Reddit Post to StumbleUpon

OAuth Class for Flex

Having just completed a simple class to handle OAuth secure authorisation used by and others, I thought I would upload it for others to use.

Its quite simple to use (I have tried to make it as simple and straightforward as possible) and there is an example FlexBuilder project that shows how the class is used with twitter.

Basic usage is split into two parts …

1) the actual request for authorisation:

private var _twitauth:OAuthManager = new OAuthManager();
_twitauth.addEventListener( OAuthEvent.ON_REQUEST_TOKEN_RECEIVED, onRequestTokenReceived );				
_twitauth.addEventListener( OAuthEvent.ON_REQUEST_TOKEN_FAILED, onRequestTokenFailed );				
_twitauth.addEventListener( OAuthEvent.ON_ACCESS_TOKEN_RECEIVED, onAccessTokenReceived );				
_twitauth.addEventListener( OAuthEvent.ON_ACCESS_TOKEN_FAILED, onAccessTokenFailed );
_twitauth.usePinWorkflow = true;

_twitauth.consumerKey = key.text;				// Your application key from your settings page
_twitauth.consumerSecret = secret.text;	// Your application secret from your settings page
_twitauth.oauthDomain = "";

// callback for "requestToken()" when request token received from twitter
private function onRequestTokenReceived( evt:OAuthEvent ):void
	// This will redirect to a web page which allows users to accept and receive a pin number
	// Normally might be best to display an alert warning user that they will get a web page
	// displayed and what they should do with it

// call this method after getting the user to enter the pin number displayed on screen
private function onSendPin():void
	if( pin.text.length != 7 )
	{ "Sorry the PIN number is incorrect, it must be 7 numbers", "Approve Application", Alert.OK );

	if( !_twitauth.validatePin( pin.text ) )
	{ "Sorry the PIN number is invalid and must have been typed incorrectly", "Approve Application", Alert.OK );

	_twitauth.requestAccessToken( Number( pin.text ) );

private function onAccessTokenReceived( evt:OAuthEvent ):void
	// Store pins and tokens ready for future requests ... might even be good to confirm
	// the customerName is what you were expected for this authorisation
	accessPin = _twitauth.accessPin;
	accessToken = _twitauth.accessToken;
	accessTokenSecret = _twitauth.accessTokenSecret;
	customerName = _twitauth.currentUserName;

	// Now I can do my tweets and whatever
	// ........

private var accessPin:Number;
private var accessToken:String;
private var accessTokenSecret:String;
private var customerName:String;

2) future requests using saved authorisation tokens:

var twitauth:OAuthManager = new OAuthManager();
twitauth.usePinWorkflow = true;
// The following variables are retrieved from where there were stored when first authorised using step 1
twitauth.accessPin = accessPin;
twitauth.accessToken = accessToken;
twitauth.accessTokenSecret = accessTokenSecret;
twitauth.consumerKey = applicationConsumerKey;
twitauth.consumerSecret = applicationConsumerSecret;
twitauth.oauthDomain = "";

// Get our signed data using above keys, ready for sending to twitter
var postData:String = twitauth.getSignedURI( "POST", "", "status=" + encodeURIComponent(tweet.text) );

// Setup our request to twitter using signed information
var httpService:HTTPService = new HTTPService;
httpService.url = "";
httpService.useProxy = false;
httpService.method = "POST";
httpService.contentType = "application/x-www-form-urlencoded";
httpService.addEventListener( "result", httpPostResult );
httpService.addEventListener( "fault", httpPostFault );
httpService.send( new QueryString( postData ).toPostObject() );

I am currently working on integrating this into my twitter client, twitcher, but there are tricky user interface issues I need to decide upon before it can be completed. Hopefully it won’t be too long and then twitcher will be one of the few (if not the only) twitter desktop app that supports oauth.

Download the OAuth Class or OAuth Twitter Example Class, and please report any bugs or comments to me so they can be looked at.

Post to Delicious Post to Facebook Post to Reddit Post to StumbleUpon