Skip to content
An objective-c bit.ly implementation using SBJSON and ASI
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
BRBitly
BRBitlySampleApp
.gitignore
LICENSE
README.md

README.md

BRBitly

BRBitly provides an Objective C wrapper class for accessing the free URL shortening services at bit.ly from iOS 4.0 or newer.

Disclosure

BRBitly was rather brazenly copied and adapted from ILBitly. I wanted to use ILBitly directly, but the existing project was already built around ASI and SBJson rather than AFNetwork and JSONkit, so I adapted it to my needs.

Dependencies

  • ASI HTTP Request - Used for the underlying network access
  • SBJson - Needed for parsing the response from bit.ly
  • You will also need an account at bit.ly including an API key

Example Usage

Shortening an URL

BRBitly *bitly = [[BRBitly alloc] initWithLogin:login apiKey:apiKey];
[bitly shorten:@"http://www.infinite-loop.dk" result:^(NSString *shortURLString) {
    NSLog(@"The shortened URL: %@", shortURLString);
} error:^(NSError *err) {
    NSLog(@"An error occurred %@", err);
}];
[bitly release];

Expanding an URL

[bitly expand:@"http://j.mp/its-your-round" result:^(NSString *longURLString) {
    NSLog(@"The expanded URL: %@", longURLString);
} error:^(NSError *err) {
    NSLog(@"An error occurred %@", err);
}];

Getting statistics on number of clicks

[bitly clicks:@"http://j.mp/qnpNBs" result:^(NSInteger userClicks, NSInteger globalClicks) {
    NSLog(@"This link has been clicked %d times out of %d clicks globally: %d", userClicks, globalClicks);
} error:^(NSError *err) {
    NSLog(@"An error occurred %@", err);
}];

See more examples in the attached sample project.

Building Xcode Documentation

BRBitly is documented in the header files using the appledoc syntax. The sample app contains a target called "Documentation" which will build the documentation and install it for use inside Xcode as a searchable and browsable docset. In order to be able to build it you will need to install appledoc on your own computer. You can get appledoc from GitHub. For more information about how to setup and build the documentation you can read this short tutorial.

Feel free to add enhanchements, bug fixes, changes and provide them back to the community!

Thanks,

Reid van Melle

Something went wrong with that request. Please try again.