简体   繁体   English

SimplePie RSS未获取发布日期

[英]SimplePie RSS Not Getting pubDate

I am using SimplePie RSS to aggregate 4 feeds and they are being sorted by the date (descending) and in the code it is set to echo out the pubDate but it is not showing it. 我正在使用SimplePie RSS聚合4个提要,并且它们按日期(降序)排序,并且在代码中将其设置为回显pubDate,但未显示它。 It just prints a blank element. 它只是打印一个空白元素。

For sanaties sake (as the code file is tens of lines long I have it in a *.txt file on my server which can be found here: http://feeds.powercastmedia.net/feeds.php.txt 出于讽刺的缘故(由于代码文件长数十行,因此我将其保存在服务器上的* .txt文件中,该文件可在此处找到: http : //feeds.powercastmedia.net/feeds.php.txt

I am completely lost. 我完全迷路了。

Cheers!, 干杯!,
Phill 菲尔

Try placing other information in the echo calls to ensure that those lines are actually being called, and that the output is being displayed in the expected manor - 尝试在echo调用中放置其他信息,以确保这些行实际上已被调用,并且输出以预期的方式显示-

<title><? echo "Title: ".$item->get_title(); ?></title>
<link><? echo "Permalink: ".$item->get_permalink(); ?></link>
<pubDate><? echo "PubDate: ".$item->get_date(); ?></pubDate>
<description><? echo "Description: ".$item->get_description(); ?></description>

This kind of "debug output" can help with debugging all sorts of things. 这种“调试输出”可以帮助调试各种东西。 It should help you figure out exactly where the problem is originating from. 它应该可以帮助您准确找出问题的根源。

Also, I noticed that you have numerous unnecessary PHP opening and closing tags, where multiple lines could be consolidated into a single, cleaner code block (Ex:) 另外,我注意到您有许多不必要的PHP开头和结尾标记,可以在其中将多行合并为一个更简洁的代码块(Ex :)

<?php if ($success): ?>
<? $itemlimit=0; ?>
<?php foreach($feed->get_items() as $item): ?>
<? if ($itemlimit==10) { break; } ?>

Could be cleaned up to be: 可以清理为:

<?php 
if($success)
{
    $itemlimit = 0;
    $items = $feed->get_items(); // This might also help, as PHP sometimes has issues when iterating through arrays returned directly from functions
    foreach($items as $item)
    {
        if($itemlimit == 0) break;
...

In fact, most of the file could be within one pair of PHP tags. 实际上,大多数文件可能在一对PHP标记内。 Just a suggestion. 只是一个建议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM