Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-12-2011, 06:22 AM   #1 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 12
billybatigol is on a distinguished road
Default Post method parameters

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.
billybatigol is offline   Reply With Quote
Old 05-12-2011, 06:59 AM   #2 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

I would try

Code:
[req setHTTPMethod:@"POST"];
[req setHTTPBody: paramData];
__________________
dany_dev is offline   Reply With Quote
Old 05-12-2011, 07:29 AM   #3 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 12
billybatigol is on a distinguished road
Default

These 2 lines are already on my code
billybatigol is offline   Reply With Quote
Old 05-12-2011, 09:53 AM   #4 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

Quote:
Originally Posted by billybatigol View Post
These 2 lines are already on my code
mmm.....right I missed the setHTTPMethod line.....

%C5%DF%F3%EF%E4%EF%F2 is an url encoded string, user and password contain character that needed to be url encoded? if so, do it.
__________________
dany_dev is offline   Reply With Quote
Old 05-12-2011, 12:20 PM   #5 (permalink)
Registered Member
 
Join Date: May 2011
Posts: 12
billybatigol is on a distinguished road
Default

Ok I understand. But unfortunately the username and the password are just standard characters and numbers.
billybatigol is offline   Reply With Quote
Reply

Bookmarks

Tags
encoding, method, post

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 363
6 members and 357 guests
doffing81, dre, iOS.Lover, Kirkout, MikaelBartlett, PlutoPrime
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:02 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0