2011-06-17 66 views
2

朋友 我想这么多,但我没有得到任何解决方案 如果他或她输入他们的用户名和密码,然后我想从web服务器数据库脸颊有价值。 如果他的用户名和密码很多,那么他将使用该应用程序。除此之外,他没有权限使用此应用程序。检查Web认证服务在iphone

+0

你有Web服务进行身份验证? – iAmitWagh 2011-06-17 06:13:38

+0

是的,我有网络服务认证,我不知道该怎么办 – Rocky 2011-06-17 06:19:20

回答

0

你可以试试这个代码: -

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]; 
0

看看ASIHTTPRequest,其中包括基本HTTP身份验证的简单方法。