ログイン後にページからソース(文字列)を取得したいだけです。ログインボタンを押すと、最初のページ(ログインページ)のソースが表示されます。正しいパスワードでも間違ったパスワードでも同じ結果になります。あなたの助けをいただければ幸いです。
`-(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]);
} `