I have a new question. I think it's something small but I can't see it myself. I can get curl to run fine at the command prompt, but not in PHP:
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";$ch = curl_init();
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIE, $mycookie); // "works" if I remove this line
$content = curl_exec($ch);
curl_close($ch);
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.
I am stumped.
Richard
On Feb 3, 2004, at 2:29 PM, Frank Sorenson wrote:
On Mon, 2 Feb 2004, Richard Miller said:Here is my code:
if (!($fh = fopen($FILENAME, "w"))) die ("Could not open " . $FILENAME . "!");
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_URL, $WSJURL); curl_setopt($ch, CURLOPT_COOKIE, $mycookie); curl_setopt($ch, CURLOPT_FILE, $fh);
fclose($fh);
curl_exec($ch); curl_close($ch);
$fh2 = fopen($FILENAME, "r");
I guess I thought it was inefficient to write the curl output to disk and then read it back in again later. If you don't save the curl output to a file it is sent to stdout. Is there a better way?
# return the result, rather than outputting to browser curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $HTML = curl_exec($ch);
Frank
----------------------------------------------------------------------- ----
Frank Sorenson - KD7TZK
Systems Manager, Computer Science Department
Brigham Young University
[EMAIL PROTECTED]
____________________ BYU Unix Users Group http://uug.byu.edu/ ___________________________________________________________________ List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list
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
