我正在尝试使用 xcode 制作登录页面。
我已阅读有关此的所有主题,并且我很确定我的应用程序已成功将用户名和密码发送到网页。
但我的问题是,当我调用响应字符串时,我仍然从网页上的登录屏幕获取源代码。当我的应用程序发送密码和用户名时,我该从哪里开始?
我使用 ASIformdatarequest 来发布用户名和密码。
这是我发送用户名和密码的代码
(Brugernavn = 用户名,Adgangskode = 密码)
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://coutbound.dk/login.asp"]];
[request setPostValue:[self.bnavn text] forKey:@"Brugernavn"];
[request setPostValue:[self.kord text] forKey:@"Adgangskode"];
[request setDelegate:self];
[request startAsynchronous];
}
- (void)requestFailed:(ASIHTTPRequest *)request {
NSLog(@"Request failed: %@",[request error]);
}
- (void)requestFinished:(ASIHTTPRequest *)request {
NSLog(@"Submitted form successfully");
NSLog(@"Response was:");
NSLog(@"%@",[request responseString]);
}
还有网页
<html>
<head>
<title>Login script</title>
<link rel=stylesheet title=std href="typografi.css" type="text/css">
</head>
<body style="background-color: transparent;">
<img border="0" src="aeble.gif" width="161" height="120">
<form method="POST" action="login.asp">
<table border="0" width="100%" height="2">
<tr>
<td width="41%" height="1">
<p align="left"><script language="JavaScript">
day = new Date()
hr = day.getHours()
if (hr < 5)
hilsen = "God aften"
if (hr >= 5)
hilsen = "God morgen"
if (hr >= 10)
hilsen = "God formiddag"
if (hr >= 12)
hilsen = "God eftermiddag"
if (hr >= 17)
hilsen = "God aften"
document.write(hilsen)
</script> og velkommen<script>
today = new Date();
document.write(' på COutbound i dag den '+today.getDate()+'. ')
tmonth = today.getMonth()
if (tmonth==0) document.write('januar ')
if (tmonth==1) document.write('februar ')
if (tmonth==2) document.write('marts ')
if (tmonth==3) document.write('april ')
if (tmonth==4) document.write('maj ')
if (tmonth==5) document.write('juni ')
if (tmonth==6) document.write('juli ')
if (tmonth==7) document.write('august ')
if (tmonth==8) document.write('september ')
if (tmonth==9) document.write('oktober ')
if (tmonth==10) document.write('november ')
if (tmonth==11) document.write('december ')
document.write(today.getUTCFullYear())
document.write('<br>')
s = 'December 24, '
if (today.getMonth()==11)
if (today.getDate()>24) {
if (today.getYear()<100)
s += today.getYear() + 1901
else s += today.getYear() +1
}
else s += today.getYear()
if (today.getMonth()==11)
if (today.getDate()==24)
document.write('<font size=+2>så idag er det Juleaften</font>')
else {
BigDay = new Date(s)
msPerDay = 24 * 60 * 60 * 1000 ;
timeLeft = (BigDay.getTime() - today.getTime());
e_daysLeft = (timeLeft / msPerDay)+1;
daysLeft = Math.floor (e_daysLeft);
document.write('der er '+daysLeft+' dage til Juleaften i ');
if (BigDay.getYear()<100)
document.write(BigDay.getYear()+1900)
else document.write(BigDay.getYear())
document.write('</font><p>')
}
</script></p>
<p style="margin: 0">Angiv brugernavn og adgangskode herunder. Har du ikke brugernavn og adgangskode skal du oprette dig som bruger
ved at klikke på linket under formularen!
</tr>
</table>
<table border="0" width="45%" height="47">
<tr>
<td width="50%" height="26">Brugernavn:</td>
<td width="50%" height="26"><input type="text" name="Brugernavn" size="25"></td>
</tr>
<tr>
<td height="26">Adgangskode:</td>
<td height="26"><input type="password" name="Adgangskode" size="25"></td>
</tr>
<tr>
<td width="100%" align="center" colspan="2"><input type="submit" value="Login" name="Action" style="font-size: 8pt"></td>
</tr>
<tr>
<td width="100%" align="center" colspan="2" height="25" valign="bottom"><a href="Login2.asp">Opret ny bruger</a>  <a href="forgotp.asp">Jeg har glemt mit kodeord</a></td>
</tr>
</table>
</form>
</body>
</html>
解决方案
我解决了我的问题,向按钮“action”发帖,值为“login”