我试图与网站进行身份验证用户名和密码...ASIHttpRequest登录身份验证问题
我使用ASIHttpRequest这样的:
- (IBAction)fetchTopSecretInformation:(id)sender{
Ustr = User.text; //Ustr and Pstr are strings
Pstr = Pass.text;
NSURL *url1 = [NSURL URLWithString:[NSString stringWithFormat:@"https://www.MySite/login/"]];
ASIFormDataRequest *request1 = [ASIFormDataRequest requestWithURL:url1];
[request1 setUseKeychainPersistence:YES];
request1.delegate = self;
request1.shouldPresentCredentialsBeforeChallenge = YES;
[request1 setRequestMethod:@"POST"];
[request1 setPostValue:User.text forKey:@"username"];
[request1 setPostValue:Pass.text forKey:@"passwd"];
[request1 setTimeOutSeconds:30];
NSLog(@"Useer :%@",User.text);
[request1 setDidFailSelector:@selector(topSecretFetchFailed:)];
[request1 setDidFinishSelector:@selector(topSecretFetchComplete:)];
[request1 startAsynchronous];
}
- (IBAction)topSecretFetchFailed:(ASIHTTPRequest *)theRequest{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Error sending request to the server" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
- (IBAction)topSecretFetchComplete:(ASIHTTPRequest *)theRequest{
int statusCode = [theRequest responseStatusCode];
NSString *statusMessage = [theRequest responseStatusMessage];
NSString *strResponse = [[theRequest responseString] stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *strFinal = [self flattenHTML:strResponse];
NSLog(@"Response :%@",strFinal);
NSLog(@"StatusCode: %d", statusCode);
NSLog(@"StatusMessage: %@", statusMessage);
}
我得到像这样的NSLog响应:
jQuery(function($) { $(".main").addClass("show-bg"); });
JavaScript seems to be disabled in your browser.
You must have JavaScript enabled in your browser to utilize the functionality of this website.
This is a demo store. Any orders placed through this store will not be honored or fulfilled.
+995 91 190601
მოგესალმებით ელექტრონული წიგნების მაღაზიაში
READERwill.com
კალათა
კალათა GEL 0,00
სავაჭრო კალათა ცარიელია.
ჩემი ბიბლიოთეკა
სურვილები
რეგისტრაცია
.
.
.
.
.
和状态代码和状态消息是
的StatusCode:200
StatusMessage:HTTP/1.1 200 OK
这是什么反应,我该如何使用这个认证
在我的web服务,如果用户名和密码是正确的“成功”消息显示和其他故障信息显示...
我得到了statusCode:200和statusMessage:Sattus代码:<3c21444f 43545950 45206874 6d6c2050 55424c49 4320222d 2f2f5733 432f2f44像这样 – Denny
'topSecretFetchComplete'方法在你的认证成功时调用。所以你在这里写代码重定向到认证后出现的其他视图 –
如果我输入了错误的密码,那么也调用topSecretFetchComplete?为什么? – Denny