- if ([NSString respondsToSelector:@selector(stringWithCString:encoding:)]) {
- responseHash = [NSString stringWithCString:buffer3 encoding:NSASCIIStringEncoding];
- } else {
- responseHash = [NSString stringWithCString:buffer3 length:strlen(buffer)];
+ authString = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)[NSString stringWithFormat:@"u=%@&s=%@", user, responseHash], NULL, NULL, kCFStringEncodingUTF8);
+ requestString = [[NSMutableString alloc] initWithString:authString];
+ [authString release];
+
+ //We can only submit ten tracks at a time
+ for (i = 0; (i < [_tracks count]) && (i < 10); i++) {
+ NSDictionary *nextTrack = [_tracks objectAtIndex:i];
+ NSString *trackString;
+
+ trackString = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)[NSString stringWithFormat:@"&a[%i]=%@&t[%i]=%@&b[%i]=%@&m[%i]=&l[%i]=%@&i[%i]=%@", i, [nextTrack objectForKey:@"artist"], i, [nextTrack objectForKey:@"title"], i, [nextTrack objectForKey:@"album"], i, i, [nextTrack objectForKey:@"length"], i, [nextTrack objectForKey:@"time"]], NULL, NULL, kCFStringEncodingUTF8);
+ [requestString appendString:trackString];
+ [trackString release];