【发布时间】:2012-02-22 21:26:00
【问题描述】:
我想使用 bit.ly 来跟踪我的 iTunes 附属链接。 我从http://target.georiot.com 获得附属链接。 它在打开直接链接(转到iTunes)时起作用。 但是当我用 bitly 缩短附属链接时,它不会出现在同一页面上。
以下是获取短网址的代码:
NSString *longURL = link;
NSString *bitlyRequestURLString = [NSString stringWithFormat:@"http://api.bit.ly/shorten?version=2.0.1&format=xml&login=%@&apiKey=%@&longUrl=%@",
@"myappname",
@"myappidentifier",
longURL];
NSURL *bitlyURL = [NSURL URLWithString:bitlyRequestURLString];
// get the short URL from bit.ly
NSError *error;
NSString *response = [NSString stringWithContentsOfURL:bitlyURL encoding:NSUTF8StringEncoding error:&error];
NSString *shortURL = @"";
NSArray *responseParts = [response componentsSeparatedByString:@"<shortUrl>"];
if ([responseParts count] > 1) {
NSString *responsePart = [responseParts objectAtIndex:1];
responseParts = [responsePart componentsSeparatedByString:@"</shortUrl>"];
if ([responseParts count] > 0) {
shortURL = [responseParts objectAtIndex:0];
}
}
最后一个重定向链接类似于“http://phobos.apple.com/WebObjects/....”
有什么想法吗? 谢谢
【问题讨论】:
-
最后一个重定向链接对我来说是正确的。怎么回事?
-
将其发送到 Itunes 时,它不会进入所需的页面
-
想要的页面是什么? apple.com 上没有的东西?
标签: ios hyperlink url-shortener bit.ly affiliate