ASIHTT prequest登录页面 [英] ASIHTTPRequest login page

查看:143
本文介绍了ASIHTT prequest登录页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尽量让一个iPhone应用程序,可以登录到使用HTTPS确保information.Now我被困在登录页面用户的Web应用程序。我不知道如何用我的应用程序登录时检查真实账户在用户的网站。我得到的回应只有200即使我把错误的帐户。

I try to make an iphone application that can login to the web application that use the https securing the user information.Now i am stuck in the login page. I don't know how to check the real account in the website of user when logging in by my application. I got the response only 200 even if i put the wrong account.

这是我的code:

- (IBAction)clickOK:(id)sender {

NSURL *url = [NSURL URLWithString:@"https://www.freelancer.com/users/login.php"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];

[request setUseKeychainPersistence:YES];
[request setDelegate:self]; 
request.shouldPresentCredentialsBeforeChallenge = YES; 

[request setRequestMethod:@"POST"];
[request setPostValue:usernameField.text forKey:@"username"];
[request setPostValue:passwordField.text forKey:@"passwd"];


request.timeOutSeconds = 30; 

[request setDidFailSelector:@selector(requestLoginFailed:)];
[request setDidFinishSelector:@selector(requestLoginFinished:)];
[request startAsynchronous];

}


- (void)requestLoginFailed:(ASIHTTPRequest *)request
{
//notify user
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Error sending request to the server" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];

}

- (void)requestLoginFinished:(ASIHTTPRequest *)request
{
int statusCode = [request responseStatusCode];
NSString *statusMessage = [request responseStatusMessage];

NSLog(@"StatusCode: %d", statusCode);
NSLog(@"StatusMessage: %@", statusMessage);

}

任何人都可以建议我如何检查真实账户这个网站,并保持用户登录?

Can anyone suggest me how to check the real account of this website and keep user login?

感谢您的帮助。

推荐答案

您已经启动异步的东西。

You've started something Asynchronously

[request startAsynchronous];

然后料想它返回的东西直线距离:

And then just expected it to return something straight away:

NSLog(@"%@",[request responseString]);
NSLog(@"%d",[request responseStatusCode]);

您需要把这样的事情:

[request setDidFinishSelector:@selector(didFinishRequest:)];

然后移动NSLogs和水蛭关闭响应到该方法的其他任何东西。

And then move your NSLogs and any other stuff that leeches off of the response into that method.

这篇关于ASIHTT prequest登录页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆