我試圖與網站進行身份驗證用戶名和密碼...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