Re: Help! Having trouble getting one XML field from this feed reliably
| From: | Yared Hufkens | Date: | Thu, 09 Feb 2012 14:10:30 +0000 |
| Subject: | Re: Help! Having trouble getting one XML field from this feed reliably | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-316566@lists.php.net to get a copy of this message | ||
I wonder why you use cURL as SimpleXML itself can load URLs:
$vastdata = new
SimpleXMLElement('http://afe.specificclick.net/?l=32259&t=x&rnd=123456',0,true);
See http://de.php.net/manual/en/simplexmlelement.construct.php
Am 09.02.2012 04:44, schrieb Rob Gould:
> 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);
>
>
>
>
>
>
>