 |
 |
|
 |
09-02-2010, 05:05 AM
|
#1 (permalink)
|
|
Registered Member
Join Date: Sep 2010
Posts: 4
|
how can i login a webwite with username and password through ASIHTTPRequest?
Quote:
<form method="post" id="loginForm" class="login-form" action="http://www.renren.com/PLogin.do" >
<p class="top clearfix">
<label for="email">username:</label><input type="text" name="email" class="input-text" id="email" tabindex="1" value=""/>
</p>
<p class="clearfix">
<label for="password">password:</label>
<input type="password" id="password" name="password" error="please input a password" class="input-text" tabindex="2" />
</p>
<div class="caps-lock-tips" id="capsLockMessage" style="display:none"></div>
<p class="savepassword">
<label title="!" for="autoLogin" class="labelCheckbox">
<input type="checkbox" name="autoLogin" id="autoLogin" value="true" tabindex="3" />
</label>
</p>
<p class="bottom"> <input type="hidden" name="origURL" value="http://www.renren.com/Home.do" />
<input type="hidden" name="domain" value="renren.com" />
<input type="submit" id="login" class="input-submit" value="login" tabindex="4" />
<span class="getpassword"><a href="http://safe.renren.com/findPass.do" stats="home_findpassword">not remember the password?</a></span>
</p>
</form>
|
i'm a noob. 
i would to use ASIFormDataRequest.
thanks awksome man.
i use the fiddler get some information.
Quote:
POST http://www.renren.com/PLogin.do HTTP/1.1
Host: www.renren.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-cn,zh;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: GB2312,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://www.renren.com/
Cookie: _r01_=1; mop_uniq_ckid=10.7.16.26_1283219788_478435532; XNESSESSIONID=d74cca71f29d; jebecookies=d11ec7e1-6857-4c24-883b-2386fa5e1a88|||||; depovince=ZJ
Content-Type: application/x-www-form-urlencoded
Content-Length: 119
email=myusername&password=mypassword&origURL=http% 3A%2F%2Fwww.renren.com%2FHome.do&domain=renren.com
|
Last edited by xlbu; 09-02-2010 at 05:11 AM.
|
|
|
09-02-2010, 08:48 AM
|
#2 (permalink)
|
|
Registered Member
Join Date: Sep 2010
Posts: 4
|
It will be something like this:
Code:
NSURL* url = [NSURL URLWithString:@"http://www.renren.com/PLogin.do"];
ASIHTTPRequest* request = [ASIFormDataRequest requestWithURL: url];
[request setPostValue: @"user account email" forKey:@"email"];
[request setPostValue: @"user account password" forKey:@"password"];
[request setPostValue: @"http://www.renren.com/Home.do" forKey:@"origURL"];
[request setPostValue: @"renren.com" forKey:@"domain"];
[request setDelegate: self];
[request startAsynchronous];
then in your delegate class(in my code I set it up to self) you have to implement some methods from ASIHTTPRequestDelegate protocol:
Code:
- (void)requestStarted:(ASIHTTPRequest *)request;
- (void)requestReceivedResponseHeaders:(ASIHTTPRequest *)request;
- (void)requestFinished:(ASIHTTPRequest *)request;
- (void)requestFailed:(ASIHTTPRequest *)request;
- (void)request:(ASIHTTPRequest *)request didReceiveData:(NSData *)data;
- (void)authenticationNeededForRequest:(ASIHTTPRequest *)request;
- (void)proxyAuthenticationNeededForRequest:(ASIHTTPRequest *)request;
|
|
|
09-02-2010, 10:40 AM
|
#3 (permalink)
|
|
Registered Member
Join Date: Sep 2010
Posts: 4
|
Quote:
Originally Posted by DaTa
It will be something like this:
Code:
NSURL* url = [NSURL URLWithString:@"http://www.renren.com/PLogin.do"];
ASIHTTPRequest* request = [ASIFormDataRequest requestWithURL: url];
[request setPostValue: @"user account email" forKey:@"email"];
[request setPostValue: @"user account password" forKey:@"password"];
[request setPostValue: @"http://www.renren.com/Home.do" forKey:@"origURL"];
[request setPostValue: @"renren.com" forKey:@"domain"];
[request setDelegate: self];
[request startAsynchronous];
then in your delegate class(in my code I set it up to self) you have to implement some methods from ASIHTTPRequestDelegate protocol:
Code:
- (void)requestStarted:(ASIHTTPRequest *)request;
- (void)requestReceivedResponseHeaders:(ASIHTTPRequest *)request;
- (void)requestFinished:(ASIHTTPRequest *)request;
- (void)requestFailed:(ASIHTTPRequest *)request;
- (void)request:(ASIHTTPRequest *)request didReceiveData:(NSData *)data;
- (void)authenticationNeededForRequest:(ASIHTTPRequest *)request;
- (void)proxyAuthenticationNeededForRequest:(ASIHTTPRequest *)request;
|
thanks for your help.i will try it.  .if some problems appear ,maybe will i trouble you.
|
|
|
10-09-2010, 12:21 AM
|
#4 (permalink)
|
|
Registered Member
Join Date: Jun 2009
Location: Australia
Posts: 180
|
I have same question on this too, but i couldnt get it to submit the form
Code:
<form name="form2" method="post" action="/webtix/welcome/welcome.do">
<input type="text" name="cardNum" id="serial" size="25" maxlength="24"/></td>
<input name="pass" type="password" id="passwd" size="25" maxlength="24"/></td>
<input class="go_btn" type="submit" value="Login" id="gobtn2" onclick="return validate(this.form);" />
</form>
Code:
NSURL* url = [NSURL URLWithString:@".../webtix/welcome/welcome.do"];
ASIFormDataRequest* request = [ASIFormDataRequest requestWithURL: url];
[request setPostValue:@"01234" forKey:@"cardNum"];
[request setPostValue:@"01234" forKey:@"pass"];
[request setDelegate: self];
[request startAsynchronous];
I still cant get data from login page...can anyone tell me what is wrong with my code?
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 277 |
| 27 members and 250 guests |
| ADY, AragornSG, Bertrand21, Dani77, Dattee, fkmtc, HDshot, HemiMG, iDifferent, IphoneSdk, jakerocheleau, JasonR, jimbo, macquitzon216, MACralik, mer10, NSeven, prchn4christ, Rudy, sacha1996, silverwiz, sneaky, spiderguy84, Sunny46, theone8one |
| Most users ever online was 1,187, 10-11-2011 at 08:09 AM. |
» Stats |
Members: 158,885
Threads: 89,230
Posts: 380,767
Top Poster: BrianSlick (7,129)
|
| Welcome to our newest member, bookesp |
|