Php - curl bug?

software development

#1

It’s small enough to post, the curl just doesn’t return the whole contents of the file there’s like 10 lines missing in the middle of what it grabs from the remote site. (I need to display a remote page in my framework - mostly works :wink:

<?php echo '<?xml version="1.0" encoding="iso-8859-1"?> ';

$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, ‘http://www.auctionarms.com/search/auctions.aspx?&ad=lope’);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
$lines = array();
$lines = explode("\n", $file_contents);

// display file line by line
// nline becase baseref doesn’t work in some browsers…
foreach($lines as $line_num => $line) {
$nline = str_replace(‘displayitem’,‘http://auctionarms.com/search/displayitem’, $line);
echo ($nline);
}

//echo $file_contents;
?>


#2

Have you tried cURL’ing and checking it by eye?

Maximum Cash Discount on any plan with MAXCASH


#3

Yep by hand does the same thing…

Problem is this version of php is so old I can’t even report it as a bug, they say upgrade first!


#4

Maybe try setting a User-Agent field in the get:
curl -A “Mozilla/4.73 [en] (X11; U; Linux 2.2.15 i686)” [ URL ]

It could be some characters are freaking it out. Try using “double quotes”.

Maximum Cash Discount on any plan with MAXCASH


#5

BINGO - My friend!!!

added
curl_setopt ($ch, CURLOPT_USERAGENT, “Mozilla/4.73 [en] (X11; U; Linux 2.2.15 i686)”)

THANKS!!!


#6

Awesome. Happy cURLing!

Maximum Cash Discount on any plan with MAXCASH