mardi 2 décembre 2014

AFNetworking POST METHOD cannot pass parameter

Sorry, I am new to AFNetworking. I was working on a project to add some post parameters to a server. Here is my code:



NSString *server_url=[NSString stringWithFormat:@"%@/AccessPoint_NewPlayerRegistration.php",server];

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];

AFHTTPRequestOperation *operation =
[manager

POST: server_url
parameters: @{@"captcha":captchaTextField.text,
@"player_name":nameTextField.text,
@"player_time_now":[NSNumber numberWithInt:[[NSDate date] timeIntervalSince1970]]
}

success:^(AFHTTPRequestOperation *operation, id JSON){

NSString *text = [[NSString alloc] initWithData:JSON encoding:NSUTF8StringEncoding];
NSLog(@"%@",text);


}

failure:^(AFHTTPRequestOperation *operation, NSError *error){
NSLog(@"%@",error);
}
];

[operation start];


The operation was successful but the server send back an error message which shows there are no parameters in the request. My parameters cannot send to server through post method.


I have been working on this problem for days:( Thanks in advance for the help.




Aucun commentaire:

Enregistrer un commentaire