stringWithContentsOfURL: login credentials?

Discussion in 'iOS Programming' started by ArtOfWarfare, Aug 12, 2013.

  1. ArtOfWarfare macrumors G3


    Nov 26, 2007
    Is there any way I could use stringWithContentsOfURL: on a page that requires users to log in to a website, for example,


    I'd like the solution to be agnostic of the specific website - I just want the user to enter a URL and optionally login credentials and for them to get the contents of the page.

    My program already works with URLs that require no login, and it's useful enough as is, but being able to work on URLs that require a login would be a cherry on top.
  2. truehybridx macrumors member

    Dec 6, 2010
    Im not sure if there would be a 1 size fits all kind of solution to this...

    Might need to look into using AFNetworking and using a POST to enter the credentials (not sure if i used the right words to describe it)
  3. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
  4. yaymath macrumors regular

    Jan 8, 2011
  5. DennisBlah macrumors 6502


    Dec 5, 2013
    The Netherlands
    You could be scanning the page beforehand and search for login form elements, 90% of username inputfields are named 'username','user','login','email'
    And password as well, 'pass','password','code'

    Based in that you could be 'predicting' how to make a user login by posting that form with user's credentials
  6. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    @OP, If you look at the NSURL class Reference you'll find that NSURL has properties named 'user' and 'password.' If you look at their descriptions you should find the answer to the question.

Share This Page