In one of my previous blog posts on Twitter API in AIR Mobile App, many blog readers had requested for coming up with a tutorial on working with Twitter API 1.1 I have been very lazy on my design/development aspects since quite long but wanted to revive those back. So, to start with my Flex/Flash skills, I thought to come up with a tutorial on using Twitter API 1.1 in an AIR Mobile App.

Basically, this won’t be much of a tutorial but a code share. To get step by step details, check this previous blog post: Twitter API in AIR Mobile App

I actually didn’t changed much in the previous code. Things which were changed mainly were the URLs and the request/response format.

public const VERIFY_CREDENTIALS:String = 
//var postRequest:OAuthRequest = new OAuthRequest(OAuthRequest.HTTP_MEHTOD_POST, 
"", {status:postTxtArea.text}, consumer, token);

The code also makes sure that the user details received from Twitter remain stored locally, so that the user doesn’t have to login again, even after the app is closed.

public function readTwitterAccess():void
var file:File = File.applicationStorageDirectory.resolvePath("tw.file");
var fileStream:FileStream = new FileStream();
if(file.exists){, FileMode.READ);
var obj:Object = fileStream.readObject() as Object;
twitterAccessObj.accessKey = obj.twitterAccessKey;
twitterAccessObj.accessSecret = obj.twitterAccessSecret;
fileStream.close();}else{trace("No File Present");}

public function writeTwitterAccess():void
var file:File = File.applicationStorageDirectory.resolvePath("tw.file");
var fileStream:FileStream = new FileStream();, FileMode.WRITE);
var obj:Object = {};
obj.twitterAccessKey = twitterAccessObj.accessKey;
obj.twitterAccessSecret = twitterAccessObj.accessSecret;

Download the FXP

Pin It on Pinterest