WORKS: curl --cookie "WSJIE_LOGIN=blahblahblah" -L -O "http://online.wsj.com/home/us"
DOESN'T WORK: $url = "http://online.wsj.com/home/us"; $filename = "wsj.html"; $mycookie = "blahblahblah";
Is that just short hand? You mean "WSJIE_LOGIN=blahblahblah", right?
Yeah, the correct line was in my code; I just copied it incorrectly to this email. Good catch on your part.
When I run the PHP it doesn't load anything and eventually times out. If I comment out the CURLOPT_COOKIE line, then the script works fine and the page loads. But then, of course, the page that loads is the login page instead of the actual content I want.
Run a packet sniffer such as ethereal[1] on your machine and compare the
requests. I ran both your examples and they each worked for me. I can't
see what could be different, but it seems obvious that *something* has
to be. A sniffer should show that.
Thanks for the idea of getting a packet sniffer. I had never used one before but I found one for Mac OS X, and installed and used it. There is a point in the transcript where the CLI version of curl sends cookies that the PHP version of curl doesn't send. Here are snippets:
CLI CURL:
192.168.001.100.63745-206.157.193.068.00080: GET /home/us HTTP/1.1
User-Agent: curl/7.10.2 (powerpc-apple-darwin7.0) libcurl/7.10.2 OpenSSL/0.9.7b zlib/1.1.4
Cookie: WSJIE_LOGIN=xyz
Host: online.wsj.com
Pragma: no-cache
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Cookie: fastlogin=xyz; wsjproducts=xyz; user_type=xyz; REMOTE_USER=xyz; UBID=xyz
PHP CURL: 192.168.001.100.63750-206.157.193.068.00080: GET /home/us HTTP/1.1 Cookie: WSJIE_LOGIN=xyz Host: online.wsj.com Pragma: no-cache Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
The PHP version of curl doesn't send a User-Agent line, which I suppose is fine. I could mimic the other one if necessary. The problems appears to be that the 5 cookies weren't sent. Why wouldn't PHP's curl send those 5 cookies? By the way, I didn't set those cookies; the server did. Without those cookies, the redirection gets stuck in an infinite loop and the content page never loads. Help?!
Richard
smime.p7s
Description: S/MIME cryptographic signature
____________________ BYU Unix Users Group http://uug.byu.edu/ ___________________________________________________________________ List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list
