Google RSS Feed를 구문 분석하려고 할 때 네트워크 오류가 발생합니다 : Chrome 및 Firefox 개발자 도구에서 500 내부 서버 오류가 발생합니다. RSS 피드 (컬 포함)를 다운로드하는 첫 번째 부분은 정상적으로 작동합니다. 구문 분석 rss 피드가 500 내부 서버 오류가 발생합니다
나는에서이 예제를 발견 http://www.joevasquez.info/development/parsing-xml-feeds-with-php-rss-and-atom/#more-63누군가가 내가 잘못 무엇을 지적 할 수 있습니까? 고맙습니다.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
if (function_exists("curl_init")){
$ch=curl_init();
//curl_setopt($ch,CURLOPT_URL,'http://www.joevasquez.info/feed/');
curl_setopt($ch,CURLOPT_URL, 'http://news.google.com/news?hl=en&topic=t&output=rss');
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
//curl_setopt($ch,CURLOPT_HEADER,0);
$data=curl_exec($ch);
curl_close($ch);
//print($data);
$doc=new SimpleXmlElement($data,LIBXML_NOCDATA);
if (isset($doc->channel)) parseRSS($doc);
function parseRSS($xml){
$cnt=count($xml->channel->item);
for ($i=0;$i<$cnt;$i++){
$url=$xml->channel->item[$i]->link;
$title=$xml->channel->item[$i]->title;
$desc=$xml->channel->item[$i]->description;
echo '<a href="'.$url.'">'.$title.'</a>'.$desc.'<br>';
}
}
?>
</body>
</html>
PHP가 500 오류를 생성 할 때마다 오류 로그에 유용한 항목이 수반됩니다. 스크립트의 시작이' php' 태그가 아닌 직접 출력이라는 것을 감안할 때, 그것은 파스 오류 일 가능성이 있습니다. 웹 서버 오류 로그를보고 찾은 메시지를 다시보고하십시오. – DaveRandom
php 전에 dtd를 제거하려고 시도했지만 여전히 같은 오류가 발생합니다. – vaanipala
지금 오류 로그를 확인하고 있습니다. – vaanipala