Code Snippet of the Week: Writing a simple Twitter iPhone Client

How difficult can it be to write a Twitter iPhone Client? Not very difficult, if you have help from various sources. All you need is to add some source files into your XCode Twitter Client project and that’s it. Well, actually, it’s not THAT easy. You need some additional steps to do. An excellent tutorial that guides you through this can be found here. We followed the steps of the tutorial and created a really simple Twitter iPhone Client that lists recent Tweets of your followers and lets you post Tweets. You can download the XCode Project from here. In order to makes things work, you have to change thew OAuth settings in the code of the TweetflowViewController:

- (void)loadView {
...
// Create a TwitterEngine and login to your account
NSString *username = @"yourUserName";
NSString *consumerKey = @"yourKey";
NSString *consumerSecret = @"yourSecret";
twitterEngine = [[MGTwitterEngine alloc] initWithDelegate:self];
[twitterEngine setUsesSecureConnection:NO];
[twitterEngine setConsumerKey:consumerKey secret:consumerSecret];
[twitterEngine setUsername:username];
OAToken *token = [[OAToken alloc] initWithKey:@"yourToken"
secret:@"youtTokenSecret"];
[twitterEngine setAccessToken:token];
[twitterEngine getHomeTimelineSinceID:0 startingAtPage:0 count:20];
[token release];
...
}

And that’s it. Now, you should be able to run your own Twitter Client.

Our next step is to integrate additional features for the support of Tweetflows, which are part of the research by Martin Treiber in the context of Web based crowdsourcing.

your coding and collaborating ikangai team

, , , ,
  • Delicious
  • Facebook
  • Digg
  • Reddit
  • StumbleUpon
  • Twitter

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>