如何直接从UIWebView将登录信息传递到网站,而无需再次登录?

编程入门 行业动态 更新时间:2024-10-10 15:28:19
本文介绍了如何直接从UIWebView将登录信息传递到网站,而无需再次登录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想使用UIWebView在我的iPhone应用程序中打开一些网站.该网站需要用户名和密码,而我拥有这些用户名和密码.

I want to open some website in my iphone app using UIWebView. The website requires username and password and I have these username and password.

我想知道是否仍然可以在没有任何登录屏幕的情况下在UIWebView中打开网站?我的意思是,因为我已经有用户名和密码,可以使用此信息自动登录网站并在UIWebView iphone应用程序上显示所需的必要页面.

I was wondering is there anyway I can open the website in my UIWebView without any login screen? I mean as I already have the username and password, can I use this information to log in to website automatically and show the required necessary page onto my UIWebView iphone app.

我只想摆脱登录网站的麻烦,因为用户在打开应用程序时已经输入了登录信息.那就多余了.

I just want to get rid of logging to website as users have already entered the login information when they open the app. Thats redundant.

非常感谢您的帮助.

谢谢.

推荐答案

我发现了一种以Objective-C方式解决此问题的方法.我们可以使用NSURLConnection来发布表单.

I have discovered way to solve this in a Objective-C way. We can use NSURLConnection to post the form.

代码:

NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"mobile.twitter/session"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; [theRequest setHTTPMethod:@"POST"]; NSString *postString = [NSString stringWithFormat:@"authenticity_token=%@&username=%@&password=%@",@"9b670208fd22850ec791",@"urUsername",@"urPWD"]; [theRequest setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]]; // create the connection with the request // and start loading the data NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if (theConnection) { // Create the NSMutableData to hold the received data. // receivedData is an instance variable declared elsewhere. receivedData = [[NSMutableData data] retain]; } else { // Inform the user that the connection failed. }

如果需要更多信息,请问我.

Ask me if you need more information.

更多推荐

如何直接从UIWebView将登录信息传递到网站,而无需再次登录?

本文发布于:2023-11-28 14:29:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642796.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:信息传递   网站   UIWebView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!