我嘗試製作一個iphone應用程序,該應用程序可以登錄到使用https保護用戶信息的Web應用程序。現在我卡在登錄頁面中。我不知道如何在我的應用程序登錄時檢查用戶網站上的真實帳戶。即使我把錯誤的帳戶,我只有200響應。ASIHTTPRequest登錄頁面
這裏是我的代碼:
- (IBAction)clickOK:(id)sender {
NSURL *url = [NSURL URLWithString:@"https://www.freelancer.com/users/login.php"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setUseKeychainPersistence:YES];
[request setDelegate:self];
request.shouldPresentCredentialsBeforeChallenge = YES;
[request setRequestMethod:@"POST"];
[request setPostValue:usernameField.text forKey:@"username"];
[request setPostValue:passwordField.text forKey:@"passwd"];
request.timeOutSeconds = 30;
[request setDidFailSelector:@selector(requestLoginFailed:)];
[request setDidFinishSelector:@selector(requestLoginFinished:)];
[request startAsynchronous];
}
- (void)requestLoginFailed:(ASIHTTPRequest *)request
{
//notify user
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Error sending request to the server" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
- (void)requestLoginFinished:(ASIHTTPRequest *)request
{
int statusCode = [request responseStatusCode];
NSString *statusMessage = [request responseStatusMessage];
NSLog(@"StatusCode: %d", statusCode);
NSLog(@"StatusMessage: %@", statusMessage);
}
任何人都可以建議我如何檢查真實賬戶這個網站,並保持用戶登錄?
感謝所有幫助
它究竟不工作? –
是「ASIAuthenticationDialog.m」您發佈的Obj-C代碼的文件嗎?你能準確地告訴我們錯誤發生在哪裏嗎? – prince