我想使用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将登录信息传递到网站,而无需再次登录?
发布评论