Archive for the ‘Twitter’ category

How to use and retain Twitter4J OAuth access token

March 1st, 2010

I  stuck in a problem that how to re use access token, once user has authenticated by Twitter (on call back URL). I got it working. There was problem in my understanding about request token vs access token. When user first time comes on call backed URL. I take request token and token secret from session and prepare the access token. Here the place where I was confused.

Now if user presses the refresh button or you want to get user information again from twitter any where in your application. You need to use the access token and this method twitter.setOAuthAccessToken(String1, String2). Because user has already been authenticated by Twitter. You can save this information in session.

HttpSession session = request.getSession();

twitter.setOAuthConsumer(Constants.CONSUMER_KEY,Constants.CONSUMER_SECRET);

if (session.getAttribute("aToken") == null){
	// request token
	String token = (String) session.getAttribute("token");
	String tokenSecret = (String)session.getAttribute("tokenSecret");
	AccessToken accessToken =
		twitter.getOAuthAccessToken(token, tokenSecret);
	twitter.setOAuthAccessToken(accessToken);

	// save the access token, that are different from request token
	session.setAttribute("aToken", accessToken.getToken());
	session.setAttribute("aTokenSecret", accessToken.getTokenSecret());

}else{
	// use the access token to authenticate user whenever you want
	twitter.setOAuthAccessToken((String)session.getAttribute("aToken"),
		(String)session.getAttribute("aTokenSecret"));
}
User user = twitter.verifyCredentials();

If you are also developing some app by using Twitter4J API on Google App Engine. Please give feedback on it.

Twitter4J Quick Tutorial: A quick tutorial on how to develop Twitter app by using Twitter4J on Google App Engine.

How to register an app with Twitter

November 23rd, 2009

If you want to develop a Twitter app. You need to register your application with Twitter. That means you should have your production URL ready before you think to start your development. When you finished with registration, you will receive consumer key and consumer secret. These unique credentials will help your app to interact with Twitter. No big deal. You can visit your all registered applications on http://twitter.com/oauth. And to register for new app you need to visit http://twitter.com/apps/new

registering_new_app_with_twitter

Some things need to consider are the call back URL and the access type. Basically call back URL will be the production level URL of your application not your local host. If you want to use Twitter for authentication, then on successful authentication your call back URL will be invoked. Access type is the operations that your app is going to do. Read-only mode is that you only want the read access. And in Read-Write mode you can send tweets and can do other operations.

twitter_setting_callback_url

And I assume that you people know how Twitter authenticates. I am telling here in steps.

  1. You app will generate a URL with unique access token
  2. Your visitor will click on that URL, which will take your the Twitter web. Where he could allow your app to access or deny
  3. On if he allows your app, he will be asked to enter his Twitter user name and password
  4. And on successful authentication, Twitter will take user to your web. By calling your mentioned call back URL

Free Twitter clients for Symbian S60 phones

October 8th, 2009

Its quite a long time I was looking for a Twitter client for my Symbian S60 phone (Nokia 5320). Earlier I used JTwitter but it gone to paid application so I only left with m.twitter.com or dabr.co.uk like website to use on.

But recently a friend queried about it and I again had a search on it and come up with two free Twitter clients.

Snaptu

Snaptu is Java based funbox. If you psnaptuhone is Java enabled, it can be installed. More than just Twitter client, it contains every thing that we need to used on Internet on daily basis. Name any social networking or daily use site, they have them on it. Almost every popular site is available as a widget, which can be added to Snaptu. The Twitter interface is very clean. To download Snaptu to your phone, point the browser of your mobile phone to this URL: m.snaptu.com

snaptu-screenshot


TweetS60

tweets60-logoTweetS60 is Symbian based applicatin. Available in .sisx file with just size of 110 Kb. Very sleek interface with basic features of tweeting. You need to signin for only once and the thing I like over Snaptu is you can set Internet access point. It means you didnt need to select your Internet access point every time it refreshed. You can download TweetS60 from here.

tweets60-screenshot

I have decided to keep both applications on my phone. I will use TweetS60 for Twitter and will use Snaptu for other Internet needs. Like cricket score, weather, images and calandar etc.

If you like this post, you may also interested to read essential softwares of Symbian S60 phones.