Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 21, 2008, 10:52 AM   #1
drivefast
macrumors regular
 
Join Date: Mar 2008
launching mobile safari with a POST request

was anybody successful in creating a POST request to be submitted to mobile safari? i feel like i'm doing the right thing, yet the server receives a GET instead of a POST.

Code:
#define BASE_URL @"http://m.someserver.com"

// create url object
NSString *urlString; NSURL *url;
urlString = [NSString stringWithFormat: @"%@/showpost.php", BASE_URL];
url = [NSURL URLWithString: urlString];

// create the request
NSMutableURLRequest *postRq = [NSMutableURLRequest requestWithURL: url];
[postRq setHTTPMethod: @"POST"];
NSLog(@"method: %@", [postRq HTTPMethod]);
		
// call safari with the url thus built
[[UIApplication sharedApplication] openURL: url];
my showpost.php test page is set to display the request method, the headers, and all this background stuff. it shows as it received a GET. i unsuccessfully tried adding data to the request body, forcing the content-type header to look like the request comes in from an html form, and PUT for the sake of it. do POST requests at least work with NSURLConnections, in your experience?

thanks everybody.
drivefast is offline   0 Reply With Quote
Old Aug 21, 2008, 11:30 AM   #2
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
I don't think it's possible to send a post request to Safari. If you need that you'd need to use UIWebView or NSURLConnection in your own app.
kainjow is offline   0 Reply With Quote
Old Aug 22, 2008, 08:50 AM   #3
Luke Redpath
macrumors 6502a
 
Join Date: Nov 2007
Yes, it doesn't make much sense to send somebody to Safari using a POST - they should be GETting something. If you just need to submit data to a server, create a POST request inside of your app as suggested above.
Luke Redpath is offline   0 Reply With Quote
Old Aug 27, 2008, 05:02 PM   #4
drivefast
Thread Starter
macrumors regular
 
Join Date: Mar 2008
well, adding a web view was pretty straightforward. now the delicate part is that every link in the web view will also open in the web view. at one point i need to get out of my app and use safari. anybody knows how to do that? i guess hunting for <a href=...> tags in the response, but how can you get the response?... hmm.
drivefast is offline   0 Reply With Quote
Old Aug 27, 2008, 06:41 PM   #5
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
See this thread: http://forums.macrumors.com/showthread.php?p=5950268
kainjow is offline   0 Reply With Quote
Old Aug 27, 2008, 11:36 PM   #6
drivefast
Thread Starter
macrumors regular
 
Join Date: Mar 2008
whoa. good idea. thanks.
drivefast is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
AT&T Launching New 'Mobile Share Value Plans' with Monthly Discount, 18-Month 'AT&T Next' Option MacRumors MacRumors.com News Discussion 133 Dec 16, 2013 10:37 AM
China Mobile Launching New Brand on December 18, Fueling Rumors of iPhone Debut MacRumors iOS Blog Discussion 3 Nov 21, 2013 10:55 PM
Virgin Mobile USA Launching iPhone on June 29 with Plans Starting at $30 MacRumors MacRumors.com News Discussion 224 Jul 26, 2013 07:17 AM
Safari not launching bmorris Mac OS X 10.7 Lion 0 Jan 9, 2013 01:00 PM
AT&T's 'Mobile Share' Service Plans Launching August 23 MacRumors MacRumors.com News Discussion 244 Sep 13, 2012 08:31 PM

Forum Jump

All times are GMT -5. The time now is 10:44 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC