Re: Open safari and send post variables
Re: Open safari and send post variables
- Subject: Re: Open safari and send post variables
- From: Yorh <email@hidden>
- Date: Fri, 9 Jun 2006 14:41:21 +0200
Hi and thank you for the support,
Your code of course works... but I need to open safari and print the
variables I sent (with php).
I know how to do it with php, but i write:
NSURL *someUrl = [NSURL URLWithString:@"http://www.test.org/
test.php"];
NSURLConnection * theConnection;
NSMutableURLRequest* postURLRequest = [NSMutableURLRequest
requestWithURL:
someUrl];
//Make it a post
[postURLRequest setHTTPMethod:@"POST"];
//Set the body for the post
[postURLRequest setHTTPBody:[@"test=foo"
dataUsingEncoding:NSISOLatin1StringEncoding]];
//Start the connection with the post
theConnection=[[NSURLConnection alloc]
initWithRequest:postURLRequest
delegate:self];
[[NSWorkspace sharedWorkspace] openURL:someUrl];
It doesn't works.
I used a sniffer to get the packets and all seems sent by my app...
How can I do?
Thanks
Yorh
On 09/giu/06, at 13:44, Conor Dearden wrote:
As you stated NSURLConnection is what you want; you just have to
look at the
documentation a bit longer:
file:///Developer/ADC Reference Library/documentation/Cocoa/
Reference/Fo
undation/Classes/NSURLRequest_Class/Reference/Reference.html
The post part would be this:
//Create a request
NSMutableURLRequest* postURLRequest = [NSMutableURLRequest
requestWithURL:
[NSURL URLWithString:@"http://www.apple.com/search"]];
//Make it a post
[postURLRequest setHTTPMethod:@"POST"];
//Set the body for the post
[postURLRequest setHTTPBody:[@"search=SomethingHere"
dataUsingEncoding:NSISOLatin1StringEncoding]];
//Start the connection with the post
theConnection=[[NSURLConnection alloc]
initWithRequest:postURLRequest
delegate:self];
You will have to read up on NSURLConnection on how to implement the
delegate
methods for reading the data.
Conor
www.bruji.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40metagraphics.it
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden