我只想在登录后从页面中检索源(字符串)。当我按下登录按钮时,它会给我第一页(登录页面)的源。无论我输入正确还是错误的密码,结果都是一样的。您的帮助将不胜感激。
`- (IBAction)buttonPressed:(id)sender {
// PERFORM LOGIN
url = [NSURL URLWithString:@"https://www.page asking username and password/"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setRequestMethod:@"POST"];
[request setPostValue:userName.text forKey:@"UserID"];
[request setPostValue:password.text forKey:@"Password"];
[request setDelegate:self];
[request setDidFailSelector:@selector(PostFailed:)];
[request setDidFinishSelector:@selector(PostFinished:)];
[request startSynchronous];
}
- (void)PostFailed:(ASIHTTPRequest *)theRequest
{
//notify user
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Error sending request to the server" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
- (void)PostFinished:(ASIHTTPRequest *)theRequest
{
//在这里获取您的回复数据...
// ATTEMPT TO ACCESS ACCOUNT SUMMARY DATA
url = [NSURL URLWithString:@"https://www.page after I loged in"];
ASIHTTPRequest *mainRequest = [ASIHTTPRequest requestWithURL:url];
[theRequest setDelegate:self];
[mainRequest startAsynchronous];
NSLog(@"Response %d ==> %@", theRequest.responseStatusCode, [theRequest responseString]);
} `