Skip to content

Instantly share code, notes, and snippets.

@michelezonca
Created November 16, 2011 04:37
Show Gist options
  • Select an option

  • Save michelezonca/1369249 to your computer and use it in GitHub Desktop.

Select an option

Save michelezonca/1369249 to your computer and use it in GitHub Desktop.
#import "Sample.h"
@implementation Sample
- (void) doAPIRequest {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@try {
// Initialize the Obj-C Client Library with a Developer key
Bitly* bitly = [[Bitly alloc] initWithKeys:@"your-public-key" mashapePrivateKey:@"your-private-key"];
// Call a method asynchronously and get a NSOperationQueue object
NSOperationQueue* queue = [bitly getShortenedUrl:@"http://www.mashape.com" login:@"bitly-login" apikey:@"bitly-api-key" callback:self];
[bitly release];
@catch (MashapeClientException *exception) {
NSLog(@"Exception with code %@ and message: %@", [exception name], [exception reason]);
}
[pool drain];
}
-(void)requestCompleted:(id) response {
// Read the API's documentation
NSString* shortenedUrl = [response valueForKey:@"shortenedUrl"];
}
-(void)errorOccurred:(MashapeClientException*) exception {
NSLog(@"Exception with code %@ and message: %@", [exception name], [exception reason]);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment