Domanda

Voglio usare Bit.ly per tenere traccia dei miei link di affiliazione iTunes. Ricevo link di affiliazione da http://target.georiot.com. Funziona quando si oppone il collegamento diretto (andando su iTunes). Ma quando accorzo il link di affiliazione con Bitly, non va sulla stessa pagina.

Ecco il codice per ottenere l'URL di accorciamento:

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

L'ultimo collegamento di reindirizzamento va qualcosa come "http: //phobos.apple.com/webjects/...."

Qualche idea? Grazie

Nessuna soluzione corretta

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top