View Single Post
Old 04-07-2009, 09:40 PM   #20 (permalink)
hayroob
Administrator
 
hayroob's Avatar
 
Join Date: Mar 2008
Location: Detroitish
Posts: 1,654
anybody know anything about html POST requests. I need to generate a POST request to work with voxBack to submit feedback. I could just add a webView for feedback, but it looks like balls, so I'm hoping that I can use native textFields to input the text and then generate a post request to replace the default voxBack form.

generic code for html POST in obj-c:
NSString *myRequestString = @"&myVariable1=Hello%20World&myVariable2=Ohai2u ";
NSData *myRequestData = [ NSData dataWithBytes: [ myRequestString UTF8String ] length: [ myRequestString length ] ]
NSMutableURLRequest *request = [ [ NSMutableURLRequest alloc ] initWithURL: [ NSURL URLWithString: @"http://www.google.com/" ] ];
[ request setHTTPMethod: @"POST" ];
[ request setHTTPBody: myRequestData ];

NSData *returnData = [ NSURLConnection sendSynchronousRequest: request returningResponse: nil error: nil ];

This will send the POST request: http://www.google.com/&myVariable1=H...riable2=Ohai2u and place any data that comes back int the NSData object returnData

voxBack form:
Feedback
__________________
If you like the KATG app feel free to kick in some bucks (or don't)
KATGIPHONE Donation

Last edited by hayroob; 04-07-2009 at 09:42 PM.
(Offline)   Reply With Quote