Prev: PHP - Header ERROR
Next: String Parse Help for novice
From: Ashley Sheridan on 13 Jun 2010 11:04 On Sun, 2010-06-13 at 16:58 +0200, David Äesal wrote: > Hello, > > I'm trying to access (from CLI) some website, where login is required. > Please, is it possible to set/save some cookies first (login session > information) and then access the website as logged user? All through CLI. > > > > Thank you very much for any information. > > > > David Cesal > I don't believe cookies are available in a CLI script, they are a construct of the browser/web server setup. Running PHP via the command line is just like any other script over the command line. Thanks, Ash http://www.ashleysheridan.co.uk
From: Shawn McKenzie on 13 Jun 2010 12:34 On 06/13/2010 09:58 AM, David Česal wrote: > Hello, > > I'm trying to access (from CLI) some website, where login is required. > Please, is it possible to set/save some cookies first (login session > information) and then access the website as logged user? All through CLI. > > > > Thank you very much for any information. > > > > David Cesal > > I'm almost positive you can do this with cURL and it should be fairly simple. Check it out. http://php.net/manual/en/book.curl.php -- Thanks! -Shawn http://www.spidean.com
From: Richard Quadling on 14 Jun 2010 07:20 2010/6/13 David Äesal <David(a)cesal.cz>: > Hello, > > I'm trying to access (from CLI) some website, where login is required. > Please, is it possible to set/save some cookies first (login session > information) and then access the website as logged user? All through CLI. > > > > Thank you very much for any information. > > > > David Cesal > > Beside cURL, you can also use stream contexts to get/set the cookie for subsequent requests. http://docs.php.net/stream_context_create http://docs.php.net/stream_get_meta_data http://docs.php.net/manual/en/context.http.php Essentially, you create a context when you send the data (this will allow you to POST data for a file_get_contents() call). Then you get the meta data from the response. Then you put the cookie you received into the context you will use to continue in communication. If you set up the default context in this way, then you don't need to supply the context to every file command. See the user notes on file_get_contents regarding routing calls through an NTLM proxy. By creating a default context, all my code was routed through an NTML proxy. PHP didn't support NTLM authentication when I wrote the note (not sure it does yet, but my requirement changed). By using a default context, I have 1 place to edit any code (in my auto_prepend.php script). Richard. -- ----- Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling
From: Richard Quadling on 14 Jun 2010 07:26 On 13 June 2010 17:34, Shawn McKenzie <nospam(a)mckenzies.net> wrote: > On 06/13/2010 09:58 AM, David Äesal wrote: >> Hello, >> >> I'm trying to access (from CLI) some website, where login is required. >> Please, is it possible to set/save some cookies first (login session >> information) and then access the website as logged user? All through CLI.. >> >> >> >> Thank you very much for any information. >> >> >> >> David Cesal >> >> > > I'm almost positive you can do this with cURL and it should be fairly > simple. Â Check it out. > > http://php.net/manual/en/book.curl.php > > -- > Thanks! > -Shawn > http://www.spidean.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- ----- Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling
|
Pages: 1 Prev: PHP - Header ERROR Next: String Parse Help for novice |