tags:

views:

44

answers:

2

Hey everyone, I am sorry if this question has already been asked/answered But I have a Cocoa program that has different arrays of models. Each model hold just Strings and one Image. Archiving and Loading works great.

Each model represents a web account, that is, it holds the username and password, and some other information related to the website. Moving forward I would like to be able to update information in each model by accessing the information from the website. For example updating a balance ($). I am wondering if there is a way to do that programatically that is:

  1. Automatically log into web account using the entered username, pass, and website url
  2. Update the balance based on the information following log in.

Thanks for the help in advance!

Tamara

+2  A: 

There is no single approach to log into any arbitrary website. You will need to know what the API for the given website is. If the website provides a web service to query things like balance, then you would connect using that web service (REST-based if at all possible; SOAP is more of a pain in Cocoa), and update your model based on the results. If the website provides no web service, then you would have to scrape through the HTML responses looking for what you want, and this is generally very complex and fragile. There is no general answer to this question; you'd have to know what form the website is in.

On another note, make sure that you are not storing user passwords in unencrypted files. User passwords on Mac should always be stored in Keychain. There are many posts on SO about how to best use Keychain.

Rob Napier
A: 

Rob, isn't it possible to just look through the login page's html source and see what are the names of the fields for user and pass, and then just send a POST request to that page from code ?

Woofy