在iphone中检查Web身份验证服务

时间:2011-06-17 06:08:31

标签: iphone objective-c

朋友 我这么努力,但我没有得到任何解决方案   如果他或她输入他们的用户名和密码,那么我想要从webserver数据库那里得到价值。 如果他的用户名和密码很多,那么他将使用该应用程序。 除此之外,他没有权限使用此应用程序。

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分: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];