Help! Having trouble getting one XML field from this feed reliably

From: Date: Thu, 09 Feb 2012 03:44:59 +0000
Subject: Help! Having trouble getting one XML field from this feed reliably
Groups: php.general 
Request: Send a blank email to php-general+get-316564@lists.php.net to get a copy of this message
Can anyone tell me what I'm doing wrong here? I'm trying to get the VASTAdTagURI field from the XML data at this url: http://afe.specificclick.net/?l=32259&t=x&rnd=123456 Here's my code. (below). It works maybe 30% of the time, but most of the time it just returns nothing from that field. Yet when I go to the above url in Firefox, I always see the data. This is very strange. // Lets get the ad! $curl_handle=curl_init(); curl_setopt($curl_handle,CURLOPT_URL,'http://afe.specificclick.net/?l=32259&t=x&rnd=123456'); curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2); curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1); $buffer = curl_exec($curl_handle); curl_close($curl_handle); $vastdata = new SimpleXMLElement($buffer); $vasturi = $vastdata->Ad->Wrapper->VASTAdTagURI; echo "If the script works, vasturi = " . $vasturi; echo "<br><br><br>"; print_r($vastdata);

« previous php.general (#316564) next »