0

These pics is what I used Charles caught. pic1 is overview. pic2 & pic3 request in form or text form, I don't know which is the right request form. pic4 is JSON I should've gotten. pic5 is after I sent my parameters what the server feed back.But it shows error code.

This is what the Charles found and I caught it.

Request

This is the request in Text tab

This is what it send back.

Now I am planning using AFNetworkingOperationManager.I don't know what the parameter is ? Here's my code

- (void)getSongSList:(NSURL *)songsListUrl{
    NSArray *array = [[NSArray alloc] initWithObjects:@"27858424", @"8738906", @"2760603" , @"7492213", @"8094802", @"12486744", @"7540057", @"8169805", @"2760613", @"7421076" ,nil];
    NSDictionary *parameters = [NSDictionary dictionaryWithObject:array forKey:@"songIds"];

    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [manager.responseSerializer setAcceptableContentTypes:[NSSet setWithObject:@"application/javascript"]];
    [manager POST:@"http://music.baidu.com/data/music/links?rate=64" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"JSON: %@", operation.responseString);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"Error: %@", error);
    }];
}

But I got error code.

Erro code

Could someone tell my what is the right parameters I should post. Or tell me the right way to do this job. Thanks a lot

here's operation.request.HttpBody log

2014-08-02 19:07:36.413 LemonFM[45892:60b] Http Body: <736f6e67 4964735b 5d3d3237 38353834 32342673 6f6e6749 64735b5d 3d383733 38393036 26736f6e 67496473 5b5d3d32 37363036 30332673 6f6e6749 64735b5d 3d373439 32323133 26736f6e 67496473 5b5d3d38 30393438 30322673 6f6e6749 64735b5d 3d313234 38363734 3426736f 6e674964 735b5d3d 37353430 30353726 736f6e67 4964735b 5d3d3831 36393830 3526736f 6e674964 735b5d3d 32373630 36313326 736f6e67 4964735b 5d3d3734 32313037 36>

6
  • there is no error code. Aug 2, 2014 at 2:24
  • what do you mean no error code?I believe I've made my words clearly.I wanna get the JSON like pic4, but it gives me a wrong JSON, just like the last pic.
    – ronan
    Aug 2, 2014 at 3:20
  • And Are my parameters right? Or I should post this parameter "songIds=27858424%2C8738906%2C2760603%2C7492213%2C8094802%2C12486744%2C7540057%2C8169805%2C2760613%2C7421076". NSDictionary *parameters= [NSDictionary dictionaryWithObject:@"27858424%2C8738906%2C2760603%2C7492213%2C8094802%2C12486744%2C7540057%2C8169805%2C2760613%2C7421076" forKey:"songIds"]
    – ronan
    Aug 2, 2014 at 3:26
  • But you know what a error code is? (Hint: 401, 404, 501,…) Aug 2, 2014 at 4:43
  • try logging operation.request.HTTPBody to console Aug 2, 2014 at 9:52

1 Answer 1

0

Solved. I was not familiar with AFNetworking before. Now I know that should post a NSDictionary parameters first, then parse the responseObject.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.