Short URLs can be created in two different ways : Bitly and TinyUrl.
I have implemented this using Bitly approach.
Include BitlyShortUrl.h and BitlyShortUrl.m file into your project [available on Github].
- (void)BitlyShortUrlSucceededWithShortUrl:(NSString *)shortUrl{
// Success in creating short URL
NSLog(@"shortUrl : %@ ",shortUrl);
}
- (void)BitlyShortUrlFailedWithError:(NSError *)error {
// Failed in creating short URL
}
BitlyShortUrl *ShortURL = [[BitlyShortUrl alloc] initWithDelegate:self];
[ShortURL BitlyUrl:longURLValue];
I have implemented this using Bitly approach.
Now, #import "BitlyShortUrl.h" in header file where functionality is to be implemented.
Specify delegate “BitlyShortUrlDelegate” in interface of header file.
#pragma mark -
#pragma mark BitlyShortUrlDelegate Methods
// Success in creating short URL
NSLog(@"shortUrl : %@ ",shortUrl);
}
// Failed in creating short URL
}
[ShortURL BitlyUrl:longURLValue];
No comments:
Post a Comment