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 ++; } ?>
私は試しましたが、このエラーが発生しましたが、「致命的なエラー:nullのメンバー関数getAttribute()を呼び出して...」 この行には、 '=> $ node-> getElementsByTagName(' enclosure ') - > item(0) - > getAttribute(' url ')、' どのように私はこれを解決することができますアイデア。私はそれがnullリファレンスを言うことを知っていますが、これを防ぐために上記のコードをどうやって修正することができますか? –