I'm a new user of "Snoopy", and am really finding it a big time-saver. What a great class extension! I've almost got it doing what I need. However, I have just one problem. I'm fetching the contents of a web page, which requires the user to login. How can I direct the normal login window that is usually sent from the target web site to the client?
Thanks for your help.
BTW, here's the response code and headers that are returned:
response code: HTTP/1.1 401 Authorization Required
0: HTTP/1.1 401 Authorization Required
1: Date: Fri, 17 Dec 2004 14:32:51 GMT
2: Server: Apache
3: WWW-Authenticate: Basic realm="Message Board"
4: Connection: close
5: Content-Type: text/html
As you can see, I'm trying to logon to a messaging board. Normally, the messaging board's loging window is sent to the client. That's what I'd still like to have done.
$snoopy->user = 'myuser';
$snoopy->pass = 'mypass';
Thanks for your reply Monti. I've been able to code in a fixed username and password, as you show. But, I need to do this a little differently to allow for various users. The page that is fetched by Snoopy is a messaging board subject listing. Normally, when the user first tires to access that page from his browser the server on which it resides normally sends back a login window requesting username and password. I want to have the same thing happen when I have Snoopy fetch that page for the first time. This may all sound a bit confusing, but what my PHP script is doing is fetching the messaging board's page, then returning it in a JS array for post processing at the client. I then present a custom version of the messaging board page. But, the user still needs to login to the messaging board as a result of my Snoopy fetch to same.
Anytime you use Snoopy as a web page scraper and there is login/authentication involved, things can get quite hairy, and typically not worth the hassle (ie. fix the problem at the source, at the web server.)
If you really have to do it this way, try examining the correspondence between the client and server (cookies, headers, content, etc.) and make sure everything is in order.