Created
November 16, 2011 04:37
-
-
Save michelezonca/1369249 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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