I have trouble login using the post method in a certain site. The parameters that I have to give are little confusing:
userName = user
pwd = pass
submit1 = %C5%DF%F3%EF%E4%EF%F2
loginTrue = login
First of all what is that "%C5%DF%F3%EF%E4%EF%F2" is? Other possibilities are that is a greek word with wrong text encoding. I know which greek word but I used it without luck. I implemented these parameters with the following code:
Code:
NSURL *url = [[NSURL alloc] initWithString:kFormURL];
NSMutableURLRequest *req = [[NSMutableURLRequest alloc]
initWithURL:url];
[req setHTTPMethod:@"POST"];
NSString *submit = @"%C5%DF%F3%EF%E4%EF%F2";
NSString *paramDataString = [NSString stringWithFormat:@"userName=user&pwd=pass&submit=%@&loginTrue=login", submit];
NSData *paramData = [paramDataString dataUsingEncoding:NSUTF8StringEncoding];
[req setHTTPBody: paramData];
[webView loadRequest:req];
Is the dataUsingEncoding:NSUTF8StringEncoding the problem?
I pass the submit1 with a NSString but I also passed it directly :
Code:
NSString *paramDataString = [NSString stringWithFormat:@"userName=cst01135&pwd=201201&submit=%C5%DF%F3%EF%E4%EF%F2&loginTrue=login"];
Secondly I am also concerned about the loginTrue = login. In a forum of the site I try to login someone wrote that the loginTrue parameter is read-only and he used something to pass login. This is the html code for these 2 parameters in case:
Code:
</SCRIPT>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0 width="500" align="center" style="margin-top:20">
<tr>
<td align=center>
<table border=0 class="tableborderColorOnly" CELLSPACING=0 CELLPADDING=0 style="width:100%">
<tr><td>
<TABLE class="tableCell" WIDTH="100%" BORDER=0 CELLSPACING=0 CELLPADDING=5 align="center">
<tr>
<td height="20" colspan=2 align="left" class="whiteheader"><b>Είσοδος Φοιτητή</b></td>
</tr>
<tr height="40" valign=bottom>
<td width=120 align="right" nowrap valign="middle"><b>Όνομα χρήστη:</b></td>
<td valign="middle" ><input id="userName" maxlength="15" name="userName" style="border: 1 solid #CCCCCC" size="20"></td>
</tr>
<tr>
<td align="right" valign="middle"><b> Κωδικός πρόσβασης:</b></td>
<td valign="middle"><input type="password" id=pwd name=pwd style="border: 1 solid #CCCCCC" size="20"></td>
</tr>
<TR height="50" valign="middle" >
<TD align="right" colspan=2>
<input type="submit" class="flatbtn" onclick="Submit()" value='Είσοδος' tabIndex=0 id=submit1 name=submit1>
</TD>
</TR>
</TABLE>
</td>
</tr>
</table>
</td>
</tr>
<tr height="50" valign="bottom"><td class=pageheader>
<div align="left" class=error id="result"></div>
</td></tr></table>
<input type="hidden" id="loginTrue" name="loginTrue" >
</FORM>
<script language=javascript>
function Submit()
{
document.getElementById("loginTrue").value="login";
}
</script>
In case you wonder when this code runs gives back an error of the site I try to login in my webView that says that this action gave an error.