質問

bit.lyを使用してiTunesアフィリエイトリンクを追跡したいと思います。アフィリエイトリンクを取得します http://target.georiot.com。直接リンク(iTunesに行く)を争うときに機能します。しかし、アフィリエイトリンクをBitlyで短縮すると、同じページには行きません。

これがURLを短縮するためのコードです:

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/....」

何か案は?ありがとう

正しい解決策はありません

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top