Pregunta

Quiero usar bit.ly para rastrear mis enlaces de afiliados de iTunes. Tengo enlaces de afiliados de http://target.georiot.com. Funciona cuando se opone al enlace directo (ir a iTunes). Pero cuando acorto el enlace de afiliado con Bitly, no va en la misma página.

Aquí está el código para obtener la URL acortada:

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

El último enlace de redirección va en algún momento como "http: //phobos.apple.com/webobjects/...."

¿Algunas ideas? Gracias

No hay solución correcta

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top