I am curling an html source. The curl will not complete unless I add var_dump in the script. When this is added the curl shows the information but without the var_dump the curl really never completes. If I add the var_dump, the curl runs displays return to browser but the next line of the script never executes. Why would this be?
Here is the section of code where curl is called:
[php]if (!file_exists($checker)){
echo “XMLLOCATION DOES NOT EXIST.”."
";
}else{
#echo "FILE FOUND. . ".$xmllocation."<br>";
// LOAD XML FILE TO GET streamURL
$xml = new SimpleXMLElement(file_get_contents($xmllocation));
if (!$xml){
echo 'ERROR WHILE PARSING DOCUMENT';
#exit;
} else{
foreach($xml->item as $item){
#$title= $item->title;
$url=$item->streamUrl;
#echo $title."<br>";
$html=curlurl($url); //curl called
if (!$html){
echo 'ERROR WHILE PARSING';
}else{
var_dump($html); //has to be here or curl does not return
$dom->loadHTML($html);
$aclass=$xpath->query('//a[@class="main-tt"]');
foreach ($aclass as $acl){;
$title[]=$acl->nodeValue;
$arr=$acl->getElementsByTagName('a');
foreach ($arr as $links){
$streampath[]= $links->getAttribute("href");
echo "LINK. . ".$title[$i]."<br>";
echo "TITLE. . .".$streampath[$i]."<br>";
$html=null;
}
}
$i++;
}
}
}
}
}[/php]
Here is the curl:
[php]Function curlurl($url){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_USERAGENT, ‘Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:13.0) Gecko/20100101 Firefox/13.0.1’);
curl_setopt($ch,CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);//0-FALSE 1 TRUE
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER ,FALSE);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,0);
curl_setopt($ch, CURLOPT_TIMEOUT,1000);
$html = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
#echo “CURLING. .”." “.$url.”
";
curl_close($ch);
#echo $httpcode;
return $html;
}[/php]