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 = "https://api.twitter.com/1.1/account/verify_credentials.json"; //var postRequest:OAuthRequest = new OAuthRequest(OAuthRequest.HTTP_MEHTOD_POST, "https://api.twitter.com/1.1/statuses/update.json", {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){fileStream.open(file, 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(); fileStream.open(file, FileMode.WRITE); var obj:Object = {}; obj.twitterAccessKey = twitterAccessObj.accessKey; obj.twitterAccessSecret = twitterAccessObj.accessSecret; fileStream.writeObject(obj); fileStream.close(); }
Hello,
I’m developing an app where eventuality the user will send a tweet when he tapt on a button.
When I run your example I do can authenticate but then I get a pin code and nothing hapens really. Should I change something or?
When running this code, ot shouldn’t be showing an option to add a pin. On first run, it should show an authentication web page from Twitter. Once that has been done, it should not show any Twitter Windows anymore. Just posting a tweet from the app whould do the work.
Hello,
thanks for your tutorials (this one & the facebook one).
It works well for me, but i want to post an Image with the tweet. Do you have an idea how to dot that from your example ?
Thans