Objective-C Http request response


	NSURL *url = [NSURL URLWithString:@"https://www.google.com/accounts/ClientLogin"];
	
	NSMutableURLRequest *loginRequest = [NSMutableURLRequest requestWithURL:url];
	
	[loginRequest setHTTPMethod:@"POST"];
		
	[loginRequest addValue:@"Content-Type" forHTTPHeaderField:@"application/x-www-form-urlencoded"];
	
	[loginRequest addValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
	
	NSString *requestBody = [[NSString alloc]
							 
							 initWithFormat:@"Email=%@&Passwd=%@&service=finance&source=%@",
							 
							 @"mars", @"1234", [NSString stringWithFormat:@"%@%d", @"ashlux-igFinance-1.0"]];
	
	[loginRequest setHTTPBody:[requestBody dataUsingEncoding:NSASCIIStringEncoding]];	
	
	NSHTTPURLResponse *response = NULL;
	
	NSData *responseData = [NSURLConnection sendSynchronousRequest:loginRequest returningResponse:&response error:nil];
	
	NSString *responseDataString = [[NSString alloc] initWithData:responseData encoding:NSASCIIStringEncoding];
	
	NSLog(@"Response from Google: %@", responseDataString);

Posted by 마르스

2009/11/12 23:41 2009/11/12 23:41
,
Response
No Trackback , a comment
RSS :
http://lasel.kr/blog/rss/response/6


블로그 이미지

냉정함을 잃지말자...!!

- 마르스