just try refining the code for the short url.
1. First try this.
NSString *urlstr = yourURL ;///here put your URL in string [urlstr retain]; NSString *apiEndpoint = [NSString stringWithFormat:@"http://ggl-shortener.appspot.com/?url=%@",urlstr]; [apiEndpoint retain]; NSLog(@"\n\n APIEndPoint : %@",apiEndpoint); NSString *shortURL = [NSString stringWithContentsOfURL:[NSURL URLWithString:apiEndpoint] encoding:NSASCIIStringEncoding error:nil]; shortURL = [shortURL stringByReplacingOccurrencesOfString:@"{\"short_url\":\"" withString:@""]; shortURL = [shortURL stringByReplacingOccurrencesOfString:@"\",\"added_to_history\":false}" withString:@""]; [shortURL retain]; NSLog(@"Long: %@ - Short: %@",urlstr,shortURL);
2. The second way below.
NSString *urlstr =[yourURL stringByReplacingOccurrencesOfString:@" " withString:@""];///your url string [urlstr retain]; NSString *apiEndpoint = [NSString stringWithFormat:@"http://tinyurl.com/api-create.php?url=%@",urlstr]; [apiEndpoint retain]; NSLog(@"\n\n APIEndPoint : %@",apiEndpoint); NSString *shortURL = [NSString stringWithContentsOfURL:[NSURL URLWithString:apiEndpoint] encoding:NSASCIIStringEncoding error:nil]; [shortURL retain]; NSLog(@"Long: %@ - Short: %@",urlstr,shortURL);
hope this helps you ...
:)
source share