Research Log of Web Science Students

Computer Science is not simply programming

Finding a Web Solution for Twitter4j: Results of Session Solution

with 3 comments

(INTRO: I can’t seem to figure out how to use Twitter4j Oauth in a web app. The code in the website only gives examples in a main method.

Googling Twitter4j Tutorial Web and other related searches returns nil useful results. Through this series of blogposts I HOPE to be able address this dearth.

My Problem: I’d like to be able to access the RequestToken and Twitter instantiations after authorizing from Twitter)

In my previous post I tried to store the RequestToken and Twitter instantiations to the Appengine’s datastore so I can use it in the callback url after the user authorises Twitter. But apparently the appengine datastore doesn’t support the RequestToken Class.

My next solution: put both instantiations in the session so I can access it in when the user is redirected to the callback url or from my(the developer’s) pov, so that I can access it in the controller class (no not the servlet I am using Spring btw).

So far I’ve been able to load the page and that means I was able to store it in the session, log returns no errors! I have no idea right now how to test views in Spring, I hope I did so the debugging I am doing here will rely more on logging.
sessionTests

Next step is to set the callback url to a controller to access it from there. Watch this space!

Update: Unit tested storing an access token to see if the datastore accepts it.

Well the test passed but really I don’t think I was able to store an access token because I didn’t receive one.

unitTest_storeAcessToken

Update: I setup the code to access the RequestToken and Twitter instantiations from the session in the controller where twitter redirects you after authorization. Apparently the two don’t get stored in the first place!

Here’s the code that logs if the two are accessed from session

authLogs

class TwitterUser btw, stores the Twitter class and the RequestToken class.

Here’s the log after Twitter redirects the user after authorization:

authlogs1

Update: Got a new lead from here. It doesn’t look realated at first but as I’ve realized it does! Hope to work on this soon.

Written by Jose Asuncion

August 24, 2009 at 4:53 pm

3 Responses

Subscribe to comments with RSS.

  1. Hi;

    Came here from your question on StackOverflow. I have posted my question related to GAE/J session handling there. http://stackoverflow.com/questions/1462681/httpsession-problem-in-google-app-engine-j

    I am following work on your blogs to develop a twitter webapp. But stuck with Sessions. If I remove session code then my servlets, then it works fine.

    If you please have a look on my posted question, so that you can give any pointer over it.

    Thank you very much.

    Tahir Akram

    September 22, 2009 at 9:32 pm

  2. [...] Finding a Web Solution for Twitter4j: Results of Session Solution [...]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.