URL shortening
Shorten any URL over at uplink.to
Calling
http://uplink.to/uplinkto.php?longurl={escaped URL string}
from any language will return the shortened URL in the http response.
Here is an example in Cocoa:
-(NSString*)shortenURL:(NSString*)url
{
CFStringRef legalStr = CFSTR("!@#$%^&()<>?{},;'[]");
NSString *escUrl = (NSString*)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
(CFStringRef)url, NULL, legalStr, kCFStringEncodingUTF8);
NSString *apiEndpoint = [NSString stringWithFormat:@"http://uplink.to/uplinkto.php?longurl=%@",escUrl];
NSError* error;
NSString* shortURL = [NSString stringWithContentsOfURL:[NSURL URLWithString:apiEndpoint]
encoding:NSASCIIStringEncoding error:&error];
if (shortURL)
return shortURL;
else
return [error localizedDescription];
}
Usage of the shortening service is governed by the site terms of service.