0

I am wondering if this is actually possible,because I am running out of solutions for my problem.The bit.ly short links are just ruining my day lol. The code below is what I am trying to pull off, but this doesn't work with bit.ly links. And it is always detecting bit.ly links first then google redirected links next.

 -(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
if ( inType == UIWebViewNavigationTypeLinkClicked ) {
 if ([[inRequest.URL absoluteString] rangeOfString:@"google"].location==NSNotFound){
        [[UIApplication sharedApplication] openURL:[inRequest URL]];
        return NO;
    }
}
return YES;
}
Moo Moo
  • 85
  • 7
  • 5
    It would be preferable for you to [edit your previous unanswered post](http://stackoverflow.com/questions/15371404/xcode-nslog-weird-hitch) about the same problem than repost. – jscs Mar 13 '13 at 00:32

3 Answers3

1

There's also the Bitly API's expand endpoint.

James Socol
  • 1,795
  • 10
  • 11
0

In order to expand the bit.ly link you'll need to make another web service call. LongUrl offers a service to expand shortened URLs. They offer a API to provide this.

You'll just have to live with the extra latency of a second request.

Richard Brown
  • 11,346
  • 4
  • 32
  • 43
  • I am not certain how to implement this. Do I need to download anything for this and how will I insert the code? – Moo Moo Mar 13 '13 at 00:56
  • Read the API, it looks pretty straightforward to me. The shortened URL is going to need to be decoded and a service like this will help you. They seemed like a good fit because they decode other shorteners as well. – Richard Brown Mar 13 '13 at 00:59
0

Heres a quick, easy and thread-safe way of getting any short URL to the original URL

Link: https://github.com/emotality/ATURLExpander

Example:

[[ATURLExpander urlEngine] expandURL:@"http://bit.ly/1dNVPAW" withBlock:^(NSError *error, NSString *longURL) {
    if (error) {
        NSLog(@"ATURLExpander ERROR : '%@'", error);
    } else {
        NSLog(@"ATURLExpander URL : '%@'", longUrl);
    }
}];
emotality
  • 12,795
  • 4
  • 39
  • 60