我的目标是向 Web 服务器发送 HTTP 请求,并为其提供用户名和密码。我把那部分记下来了,它出人意料地奏效了。但是,要真正登录,必须单击“登录”按钮。这完全难住了我??
NSLog(@"Connection started");
NSURL *loginPage = [NSURL URLWithString:@"www.A_WEBSITE.com"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:loginPage];
[request setRequestMethod:@"POST"];
[request setPostValue:@"Username" forKey:@"ct100_plnMain_txtLogin"];
[request setPostValue:@"Password" forKey:@"ct100_plnMain_txtPassword"];
[request start];
NSLog(@"it worked");
[request setDidFailSelector:@selector(AttemptFail:)];
[request setDidFinishSelector:@selector(AttemptSucceed)];
NSError *error = [request error];
if (!error) {
NSString *response = [request responseString];
NSLog(@"%@",response);
}
else {
NSLog(@"%@",[request error]);
}
鉴于我有它的 ID,有谁知道我可以触发按钮上的点击事件的方法?