0

我想知道这是否真的可行,因为我的问题已经没有解决方案了。bit.ly 短链接毁了我的一天,哈哈。下面的代码是我想要实现的,但这不适用于 bit.ly 链接。它总是先检测 bit.ly 链接,然后再检测 google 重定向链接。

 -(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;
}
4

3 回答 3

1

还有 Bitly API 的扩展端点。

于 2013-07-16T15:23:01.527 回答
0

为了展开 bit.ly 链接,您需要进行另一个 Web 服务调用。 LongUrl提供了扩展缩短 URL 的服务。他们提供了一个API来提供这个。

您只需要忍受第二个请求的额外延迟。

于 2013-03-13T00:40:32.240 回答
0

这是将任何短 URL 获取到原始 URL 的快速、简单且线程安全的方法

链接: https ://github.com/emotality/ATURLExpander

例子:

[[ATURLExpander urlEngine] expandURL:@"http://bit.ly/1dNVPAW" withBlock:^(NSError *error, NSString *longURL) {
    if (error) {
        NSLog(@"ATURLExpander ERROR : '%@'", error);
    } else {
        NSLog(@"ATURLExpander URL : '%@'", longUrl);
    }
}];
于 2015-01-29T13:38:43.377 回答