This是我的XML格式.ATOM供稿。我收到以下警告。cURL请求.ATOM供稿问题
我面临的问题是试图从ATOM URL中提取数据并将其显示为PHP代码并将其保存到数据库中。我不断收到这些错误...
我试过使用loadfile
,curl
,vardump()
并没有任何工作。
警告: 使用simplexml_load_file(https://colourpop.com/collections/all.atom): 未能打开流:HTTP请求失败! HTTP/1.1 403禁止在 /public_html/ecomcharts/beta/indexproducts.php上线226
警告:使用simplexml_load_file():I/O警告:未能加载外部 实体 “https://colourpop.com/collections/all.atom” 在 /的public_html/ecomcharts在线/beta/indexproducts.php 226布尔(假)
警告:的SimpleXMLElement :: __结构():实体:行1:分析器错误 :开始标记预期, '<' 不 /的public_html/ecomcharts发现/beta/indexproducts.php 228行
警告:的SimpleXMLElement :: __结构(): https://colourpop.com/collections/all.atom在 //ecomcharts/beta/indexproducts.php上线228
我不知道什么是错的。这是我的PHP代码:
<?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 . "\n";
}
?>
您到目前为止尝试过哪些操作失败?如果您手动执行控制台的cURL请求,您会看到什么?请用上述信息编辑您的问题,以便有人能够帮助您。 –
好的我编辑它:) –
如果你从控制台手动尝试cURL命令,你会得到一个错误吗? –