我有一个附加了访问代码的Webservices URL.我需要将访问代码发布到webservices url并获取json响应.我正在使用正确的访问代码和错误的访问代码获得json响应.我没有得到问题所在.我需要在输入错误密码时显示警报,这是我的代码..
NSString *post =[[NSString alloc] initWithFormat:@"txtsecurecode=%@",[txtsecurecode text]];
NSLog(@"PostData: %@",post);
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://my example.com/Accountservice/Security/ValidateAccess?accesscode=abcdtype=1"]]];
NSURL *url;
// I need to parse it into url here .
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSURLConnection *conn= [[NSURLConnection alloc] initWithRequest:request delegate:self];
if(conn)
{
NSLog(@"Connection Successful");
}
else
{
NSLog(@"Connection could not be made");
}
NSString *responseData = [[NSString …Run Code Online (Sandbox Code Playgroud)