views:

288

answers:

3

Hello,

How can I post a full hyperlink with its parameters to another link in objective-c?

Like: url=http://www.test.de/index.php?param1=23&param2=23&param3=345

Thanks

A: 

Hello,

i know how i can send parameters via post. But i need to post a full link.

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"localhost/test.php"]];    
[request setHTTPMethod:@"POST"];

NSString *postString = [[NSString alloc] init];
postString = @"url=http://www.domain.com/index.php?page=15&xml=true&page=2";

[request setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];

NSURLConnection *theConnection =[[NSURLConnection alloc] initWithRequest:request delegate:self];

But my php var_dump looks like this:

(url =>http://www.domain.com/)
(page =>15)
(xml =>true)
(page =>2)

but i need this one:
(url=>http://www.domain.com/index.php?page=15&xml=true&page=2)

thanks for the fast replys. Alex

Alexander
A: 

Hello,

i've got it. I have to encoding the url link before sending the post value.

Here the function if someone need:

- (NSString *)urlEncodeValue:(NSString *)str
{
    NSString *result = (NSString *) CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)str, NULL, CFSTR("?=&+"), kCFStringEncodingUTF8);
    return [result autorelease];
}

Thanks.

Alexander