I'm trying to send the content of a contact form to my webservice. My code is based on a StackOverFlow topic named : Sending get method in Xcode .
I think i follow the rules but it still doesn't work. I don't want u to lose your time, but i'm starting to get mad.
- (IBAction)send:(id)sender{
NSString *get = [[NSString alloc] initWithFormat:@"&Contact%%5BFirstName%%5D=%@+First&Contact%%5BLastName%%5D=%@+Last&Contact%%5BMail%%5D=%@&Contact%%5BPhone%%5D=%@&Contact%%5BMotivations%%5D=%@&Contact%%5BCommentaires%%5D=%@",prenomtxtfield.text,nomtxtfield.text,emailtxtfield.text,teltxtfield.text,pvController.mail.motiv,questiontxtview.text];
NSData *getData = [get dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *getLength = [NSString stringWithFormat:@"%d", [getData length] ];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"http://xxx.zfort.net/index.php?r=site/contactAdd"]];
[request setHTTPMethod:@"GET"];
[request setValue:getLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:getData];
My fields are : Last Name , First Name , Mail, Phone , Motiv, Question . My webservice addr is : http://xxx.zfort.net/index.php?
Thank you all (even you're not responding... you've all already helped me in the past with your comments)
PS: it may be an issue of encoding values ?
You should either change the method to "POST" or
Try this:
Then you haven to implement
and
from
https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html