开发者

How to log in to a website in iOS?

开发者 https://www.devze.com 2023-02-14 20:54 出处:网络
In an IPhone app, I am trying to figure out the correct approach to allow a user to log in to a website with a username and password, then after succeeding, subsequent requests from the app can access

In an IPhone app, I am trying to figure out the correct approach to allow a user to log in to a website with a username and password, then after succeeding, subsequent requests from the app can access secured webservice urls of the 开发者_如何学Gowebsite without the need to authenticate again - because the webservice maintains an authenticated session from the client.

I also need to support multiple threads being able to 'share' this same authenticated status and make concurrent requests to these secured urls. For example, the app logs in once, then a timer background task runs every minute to hit one secured url while the main thread makes its own user driven secured url requests.

I have not been able to find any reference on how to accomplish this in iOS and would greatly appreciate some guidance on how to go about it.


John

Check out NSURLConnection's connection:didReceiveAuthenticationChallenge: in the documentation, it handles all of the most common types of web login and authentication. Each connection on each thread needs to respond using the above protocol.

H


Well you need to use parsing whether it may be XML,Jason,ASIHTTP ,you then need to pass parameters as e.g. username and password.When you pass the parameter then you will get a response from the webservice true or false .Then you can provide the acess further if you get the right response.You can check NSURLConnection,NSURL .You can simply use the SAX .XML parsing.This will help you.If you want more help,then let me know i can send you the code as well

0

精彩评论

暂无评论...
验证码 换一张
取 消