gpt4 book ai didi

iphone - 在iPhone中登录系统。

转载 作者:行者123 更新时间:2023-12-01 16:54:44 25 4
gpt4 key购买 nike

我是iPhone互联网编程的新手。我正在编写一个具有登录屏幕的应用程序。

我正在使用ASIHTTPREQUEST,这是我要登录的链接myurl.com/index.php。在chrome中,当我使用用户名和密码登录系统时,我从开发者控制台查看了该url发布到myurl.com/ajax/login.php的信息。

无论如何,当我在应用程序中输入用户名和密码后单击登录按钮时,它不会登录系统。它会打印 FAIL:1(当我编写myurl.com/ajax/login.php时,看到FAIL:1 在浏览器中。)

我的问题的详细说明:

“myurl.com/index.php中有一个登录屏幕。在Web浏览器中,如果我输入用户名和密码,它将发布到myurl.com/ajax/login.php(从开发者控制台)。无论如何,在应用程序,我已将myurl.com/index.php作为url编写,但是当我请求时,它将在控制台中打印该页面的html元素。在控制台中。(通常在Web浏览器中,我编写了myurl.com/ajax/login.php,它给出了FAIL:1的错误)”

编辑:我已经解决了问题,“forKey:@”用户名“必须等于” forKey:@“ID”,“forKey:@”密码“需要等于” forKey:@“PWD”。因为在开发人员控制台中,用户名和密码作为ID和PWD返回。感谢您的评论和答复。

这是代码:

-(IBAction)login:(id)sender 
{
NSURL *url = [[NSURL alloc] initWithString:@"https://myurl.com/index.php"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setTimeOutSeconds:120];
[request setPostValue:studentid.text forKey:@"username"];
[request setPostValue:starspassword.text forKey:@"password"];
[request setDelegate:self];
[request startAsynchronous];
[url release];
}

-(void) requestFinished:(ASIHTTPRequest *)request
{
NSString *responseString = [request responseString];
UIAlertView *alert= [[[UIAlertView alloc] initWithTitle:@"Success" message:@"http works"
delegate:self cancelButtonTitle:@"okay" otherButtonTitles:nil] autorelease];

[alert show];
NSLog(@"SUCCESS: %@", responseString);
//Request succeeded
}

-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
}

-(void) requestFailed:(ASIHTTPRequest *)request
{
NSError *error = [request error];
NSLog(@"ERROR: %@", [error localizedDescription]);

UIAlertView *alert= [[[UIAlertView alloc] initWithTitle:@"fail" message:@"http fails" delegate:self cancelButtonTitle:@"okay" otherButtonTitles:nil]autorelease];
[alert show];
//Request failed
}

对不起,我的英语,有一些有关此主题的示例,但我没有解决此问题。谢谢你的建议。

最佳答案

您是否尝试过呢? ASI包括一种进行基本身份验证的方法

[request setUsername:studentid.text];
[request setPassword:starspassword.text];

向下滚动到处理HTTP身份验证

http://allseeing-i.com/ASIHTTPRequest/How-to-use

关于iphone - 在iPhone中登录系统。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12679209/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com