Question

Je veux utiliser bit.ly pour suivre mes liens d'affiliation iTunes. J'obtiens des liens d'affiliation de http://target.georiot.com. Cela fonctionne lors de l'oppression du lien direct (aller à iTunes). Mais lorsque je raccourcit le lien d'affiliation avec Bitly, il ne se passe pas sur la même page.

Voici le code pour obtenir l'URL de raccourci:

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];
    }
}

Le dernier lien de redirection va quelque chose comme "http: //phobos.apple.com/webobjects / ...."

Des idées? Merci

Pas de solution correcte

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top