我有一块PHP正在与我的RSS源交谈并导入它。问题是,它决定返回500内部服务器错误,我似乎无法弄清楚原因。我已将此代码与之前的Feed一起使用,但效果非常好。但是这个新的饲料打破了。有任何想法吗?
提前致谢!
<?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 ++; } ?>
答案 0 :(得分:1)
您的代码运行正常。您可以在另一台PC上尝试相同的代码