SimplePie RSS 未获取 pubDate

发布于 2024-12-12 02:31:31 字数 300 浏览 0 评论 0原文

我正在使用 SimplePie RSS 聚合 4 个提要,它们按日期(降序)排序,并且在代码中设置为回显 pubDate,但没有显示它。它只打印一个空白元素。

为了理智起见(由于代码文件有几十行长,我将其放在服务器上的 *.txt 文件中,可以在此处找到:http://feeds.powercastmedia.net/feeds.php.txt

我完全迷失了。

干杯!,
菲尔

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. 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

I am completely lost.

Cheers!,
Phill

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以往的大感动 2024-12-19 02:31:31

尝试在 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>

这种“调试输出”可以帮助调试各种事情。它应该可以帮助您准确地找出问题的根源。

另外,我注意到您有许多不必要的 PHP 开始和结束标记,其中多行可以合并为一个更干净的代码块(例如:)

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

可以清理为:

<?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;
...

事实上,大部分文件可能在一个内一对 PHP 标签。
只是一个建议。

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 -

<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 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.
Just a suggestion.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文