iphone - 登录时不显示登录页面

标签 iphone authentication nsurlconnection

我正在编写一个应用程序,它将在基于成员(member)的网站上显示文章。

我们希望应用程序能够阅读和显示设置为“仅限成员(member)”的文章 - 即使应用程序所有者不是成员(member)。

所以我希望能够在不向应用程序用户显示任何用户或密码信息的情况下登录。

当我尝试访问仅限成员(member)的文章时,我收到重定向,但没有收到身份验证质询。

有什么想法可以让我的应用程序自动登录吗?

这是表单的样子。我是否必须在 POST 请求中包含所有输入值?

<FORM ACTION="https://www.mysite.com/cgi-bin/mysite/process" METHOD=POST>
<input type="hidden" NAME="mv_todo"  VALUE="return">
<input type="hidden" name="mv_session_id" value="DySUxWM5">
<INPUT TYPE="hidden" name="mv_success_variable_hash" VALUE="">
<INPUT TYPE="hidden" name="mv_success_variable_hash_colon" VALUE="">
<INPUT TYPE="hidden" NAME="mv_successpage" VALUE="index">
<input type="hidden" name="mv_failpage" value="login">

<input value="1942255628Hx0xE2S5iCw0caMyNmrf7j2ROvvM0QUJoEVLVz+2PRq4Jjs4azdjrjWSnwN7JkIr" name="form_fn" type="hidden"><input value="login" name="form_page" type="hidden"><input value="1" name="login_form_2_revisit" type="hidden"><table cellpadding="4" class="standard_form">
<tr><td colspan="2"><font color=red><b>New Visitors:</b></font> <a href="http://www.mysite.com/cgi-bin/mysite/account_create.html">Create a new account</a></td></tr>
<tr><td class="standard_form_field"><b>Username:</b></td>
<td colspan="1"><input maxlength="64" name="mv_username" onChange="if (this.value.match(/(^\s+)|(\s+$)/)){this.value = this.value.replace(/(^\s+)|(\s+$)/g,'');}if (this.value.match(/^$/) && !this.getAttribute('js_init_now')) {alert('This is a required field. Please make sure that it is not empty.'); this.focus();this.select();return false; }; " type="text" size="15"></td></tr>

<tr><td class="standard_form_field">Password:</td>
<td colspan="1"><input name="mv_password" type="password" size="15"></td></tr>
<tr><td colspan="2"><input value="1" name="persistent_login" type="checkbox"> Remember my login info.</td></tr>
<tr><td colspan="2"><input value="" name="login_complete_param" type="hidden"> <input value="Continue..." name="ig_click form-method:continue" type="submit" class="coolButton"></td></tr>
</table>
<p ></p>

</form>

最佳答案

使用http://allseeing-i.com/ASIHTTPRequest/库比标准 NSURL 请求更容易使用。如果您喜欢查看工作示例,还有很多非常好的示例代码。我最近在一个项目中使用了它,它运行得非常好,我必须自动登录到一个网站,它运行得很好。祝你好运。

编辑:

查看您刚刚发布的表单。此代码应该可以帮助您了解如何使用 ASIHTTPREQUEST 库提交表单。这应该可以帮助您开始...:D

NSURL *url = [NSURL URLWithString:@"https://www.mysite.com/cgi-bin/mysite/process"];
ASIFormDataRequest *requestPOST = [ASIFormDataRequest requestWithURL:url];
[requestPOST setPostValue:@"return" forKey:@"mv_todo"];
[requestPOST setPostValue:@"DySUxWM5" forKey:@"mv_session_id"];
[requestPOST setPostValue:@"" forKey:@"mv_success_variable_hash"];  
[requestPOST setPostValue:@"" forKey:@"mv_success_variable_hash_colo"];
[requestPOST setPostValue:@"index" forKey:@"mv_successpage"];                   
[requestPOST setPostValue:@"login" forKey:@"mv_failpage"];                 
[requestPOST setPostValue:@"942255628Hx0xE2S5iCw0caMyNmrf7j2ROvvM0QUJoEVLVz+2PRq4Jjs4azdjrjWSnwN7JkIr" forKey:@"form_fn"];
[requestPOST setPostValue:@"login" forKey:@"form_page"];
[requestPOST setPostValue:@"1" forKey:@"login_form_2_revisit"];
[requestPOST setPostValue:@"PUT YOUR USERNAME VARIABLE IN HERE" forKey:@"mv_username"];
[requestPOST setPostValue:@"PUT YOUR PASSWORD VARIABLE IN HERE" forKey:@"mv_password"];
[requestPOST setPostValue:@"1" forKey:@"persistent_login"];
[requestPOST setPostValue:@"" forKey:@"login_complete_param"];
[requestPOST setPostValue:@"Continue..." forKey:@"ig_click form-method:continue"];
[requestPOST start];

关于iphone - 登录时不显示登录页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2075775/

相关文章:

javascript - iPhone 上的网格布局很小

wordpress - 如何在登录wordpress时检查用户状态

php - Zend Framework 2 - 使用 ZFCUser 进行身份验证的全局检查

ios - NSURLConnection的奇怪错误代码4294966295

iphone - 进入后台时 Gamekit 继续 session

iphone - 使用 iOS Developer Enterprise Program 进行 Beta 测试?

iphone - XCode-语音记录并保存到NSBundle中

php - 配置导航栏在不同类型的用户登录 Laravel 5.2 时显示不同的按钮

xcode - NSMutableData setLength :NSUInteger crashing the app

ios - 从 NSURLConnect.SendAsyncronousRequest 返回值