Continuing from my part 1, in this section, we will discuss about how to use this helper in your own application.

Source Code

Download the source code here
MKBitlyHelper 1.0.zip

Documentation


With just three lines of code, you can shorten your URL using this wrapper.

Initialize the helper class with your loginname and apikey.

bitlyHelper = [[MKBitlyHelper alloc] initWithLoginName:@"yourlogin" andAPIKey:@"yourapi"];

In your application, you can either provide your application specific API or user provided API. Logging into the bit.ly api helps in tracking the click throughs and referrals. The classes doesn’t provide a login or APIKey by itself.


Now, shortening or expanding URLs is as easy as calling these functions.

NSString *shortURL = [bitlyHelper shortenURL:@"http://mugunthkumar.com"];
NSString *longURL = [bitlyHelper expandURL:shortURL];

Disclaimers and other yada yada…


Be forewarned that it may have errors. As Donald Knuth says,

Beware of bugs in the above code; I have only proved it correct, not tried it.

Feel free you use this code and re-distribute it. The source code must retain the copyrights and my attribution in any derivative works of the source code.

On your application, you might opt to attribute me in your app though it’s not mandatory. I would be happy if you do so ;-)

If you enjoyed this post, make sure you subscribe to my RSS feed!

Related posts:

  1. iPhone Tutorial: Follow Cost API and a open source wrapper What is Follow Cost? Follow Cost is a interesting and...
  2. XCode Tip: Objective-C Singleton Class Template I have a habit of creating Singleton pattern classes for...
  3. iPhone Tutorial: Scheduling Local Notifications using a Singleton class In iOS 4, Apple introduced a new way to send...
  4. iPhone Tutorial: Better way to check capabilities of iOS devices The iPhone OS started off with a single device, the...
  5. iPhone Tutorial – UISearchDisplayController with NSPredicate Though UISearchDisplayController is seemingly easy (and yes it’s easy), apart...

7 Responses to “bit.ly wrapper for Objective-C/iPhone”

Leave a Reply