This is my XML format .ATOM feed. I am getting the following WARNINGS.
I am facing issues trying to extract the data from the ATOM URL and display it as a PHP code and save it to the DATABASE. I keep getting these errors...
I have tried using loadfile
, curl
, vardump()
and nothing worked.
Warning: simplexml_load_file(https://colourpop.com/collections/all.atom): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in /public_html/ecomcharts/beta/indexproducts.php on line 226
Warning: simplexml_load_file(): I/O warning : failed to load external entity "https://colourpop.com/collections/all.atom" in /public_html/ecomcharts/beta/indexproducts.php on line 226 bool(false)
Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : Start tag expected, '<' not found in /public_html/ecomcharts/beta/indexproducts.php on line 228
Warning: SimpleXMLElement::__construct(): https://colourpop.com/collections/all.atom in //ecomcharts/beta/indexproducts.php on line 228
I am not sure what is wrong. This is my PHP code:
<?php
$url = 'https://colourpop.com/collections/all.atom';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
$data = curl_exec($curl);
curl_close($curl);
function download_page($path) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$path);
curl_setopt($ch, CURLOPT_FAILONERROR,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$retValue = curl_exec($ch);
curl_close($ch);
return $retValue;
}
$sXML = download_page('https://colourpop.com/collections/all.atom');
echo $sXML;
$xml=var_dump(simplexml_load_file('https://colourpop.com/collections/all.atom'));
$oXML = new SimpleXMLElement('https://colourpop.com/collections/all.atom');
foreach($oXML->entry as $oEntry) {
echo $oEntry->title . "
";
}
?>