2016-10-08 2 views
1

RSS 피드와 통신중인 PHP 블록이 있습니다. 문제는 500 내부 서버 오류를 반환하기로 결정했기 때문에 이유를 파악할 수없는 것입니다. 나는이 코드를 이전 피드와 함께 사용했으며 완벽하게 작동했습니다. 그러나이 새로운 사료와 함께 그것은 부서집니다. 어떤 아이디어?RSS 피드 가져 오기 500 내부 서버 오류가 발생했습니다

미리 감사드립니다.

<?php 
    $doc = new DOMDocument(); 
    $doc->load('http://guiltyfeminist.com/rss'); 
    $cnt=0; 

    foreach ($doc->getElementsByTagName('item') as $node) { 
    $itemRSS = array ( 
    'maintitle' => $node->getElementsByTagName('title')->item(0)->nodeValue, 
    'link' => $node->getElementsByTagName('link')->item(0)->nodeValue, 
    'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue, 
    'enclosure' => $node->getElementsByTagName('enclosure')->item(0)->getAttribute('url'), 
    ); 
    ?> 
    <div class="showcontent"> 
     <div class="contentleft"> 
     <img src="<?php echo $node->getElementsByTagNameNS('http://www.itunes.com/dtds/podcast-1.0.dtd', 'image')->item(0)->getAttribute('href'); ?>"> 
     </div> 
     <div class="contentright"> 
      <h2><a href="<?php echo $itemRSS['link']; ?>"><?php echo $itemRSS['maintitle']; ?></a></h2> 
      <p><strong>Duration</strong> <?php echo $node->getElementsByTagNameNS('http://www.itunes.com/dtds/podcast-1.0.dtd', 'duration')->item(0)->nodeValue; ?></p> 
      <p><strong>Published</strong> <?php echo $itemRSS['date']; ?></p> 
      <audio controls> 
       <source src="<?php echo $itemRSS['enclosure']; ?>" type="audio/mpeg"> 
      Your browser does not support the audio element. 
      </audio> 
     </div> 
    </div> 

    <?php $cnt ++; } ?> 

답변

1

코드가 정상적으로 작동합니다. 다른 컴퓨터에서 동일한 코드를 시도 할 수 있습니다

+0

시도했지만이 오류가 발생합니다. "치명적인 오류 : null의 멤버 함수 getAttribute() 호출 ..." 이 줄은 다음과 같습니다. '=> $ 노드 -> getElementsByTagName ('인클로저 ') -> 항목 (0) -> getAttribute ('URL '),' 어떻게 해결할 수있는 아이디어. null 참조라고하지만이 문제를 방지하려면 위의 코드를 어떻게 수정할 수 있습니까? –

관련 문제