Would like to ask you a master, to achieve http what kind?
Can you put the sample source code?
Thank you. .
Reply:
/ / prepar request
NSString * urlString = [NSString stringWithFormat: @ "http://urlToSend.com"];
NSMutableURLRequest * request = [[[NSMutableURLRequest alloc] init] autorelease];
[Request setURL: [NSURL URLWithString: urlString]];
[Request setHTTPMethod: @ "POST"];
/ / Set headers
NSString * contentType = [NSString stringWithFormat: @ "text / xml"];
[Request addValue: contentType forHTTPHeaderField: @ "Content-Type"];
/ / Create the body
NSMutableData * postBody = [NSMutableData data];
[PostBody appendData: [[NSString stringWithFormat: @ ""] dataUsingEncoding: NSUTF8StringEncoding]]; "] dataUsingEncoding: NSUTF8StringEncoding]];
[PostBody appendData: [[NSString stringWithFormat: @ ""] dataUsingEncoding: NSUTF8StringEncoding]];
[PostBody appendData: [[NSString stringWithFormat: @ "
/ / Post
[Request setHTTPBody: postBody];
/ / Get response
NSHTTPURLResponse * urlResponse = nil;
NSError * error = [[NSError alloc] init];
NSData * responseData = [NSURLConnection sendSynchronousRequest: request returningResponse: & urlResponse error: & error];
NSString * result = [[NSString alloc] initWithData: responseData encoding: NSUTF8StringEncoding];
NSLog (@ "Response Code:% d", [urlResponse statusCode]);
if ([urlResponse statusCode]> = 200 && [urlResponse statusCode] <300) {
NSLog (@ "Response:% @", result);
/ / Here you get the response
}
Reply:
Thank you. . . . .
Reply:
Is so grateful!
No comments:
Post a Comment