checking the web Authentication services in iphone
friend I am trying so much but I didn't get any solution if he or she enter 开发者_运维百科their username and password then i want cheek there value from webserver database. If his username and password is much there only after then he will use the application . other then that he doesn't have permission use this application.
You can try this code:-
NSString *post = [NSString stringWithFormat:@"Loginkey=%@&Password=%@&DeviceCode=%@&Firmware=%@&IMEI=%@",txtUserName.text,txtPassword.text,model,sysver,udid];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSLog(@"%@",postLength);
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:@"http://191.16.0.6:91/JourneyMapperAPI?RequestType=Login"]]; //add your web service url here
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
Take a look at ASIHTTPRequest
, which includes simple methods for basic HTTP authentication.
精彩评论