Search code examples
phphtmlrssfeed

Why I'm getting static links and my RSS feeds are not updating?


I tried to get educational news feed from a newspaper RSS feeds but all I end up is the static links on my online page.

This is the file for getting RSS feeds:

<html>
    <style>
    .link { font-family: Arial; font-size: 12px; line-height: 1.4;}
    </style>
<body>
<?php
$html   = "";
$url    = "http://timesofindia.indiatimes.com/rssfeeds/913168846.cms";
$xml    = simplexml_load_file($url);
for ($i=0; $i<5; $i++){
    $title = $xml->channel->item[$i]->title;
    $description = $xml->channel->item[$i]->description;
    $link = $xml->channel->item[$i]->link;
    $pubDate = $xml->channel->item[$i]->pubDate;
    $html .= "<div><h3 class='link'><a href='$link' target='_blank'>$title</a></h3> - $pubDate</div>";
}
echo $html;
?>
</body>
</html>

I have included this page as: <p><?php include_once'timesOfIndiaEducationRss.php';?></p>

But my online version is showing static links like these: <a href='http://timesofindia.indiatimes.com/home/education/news/shah-pitches-for-linking-education-system-with-countrys-cultural-ethos/articleshow/59611383.cms' target='_blank'>Shah pitches for linking education system with country's cultural ethos</a></h3> - Sat, 15 Jul 2017 16:20:21 GMT</div><div><h3 class='link'></div>

Also, these are not auto-updating... To my surprise I found this CDN script placed in my header: <script src="/cdn-cgi/apps/head/ZrZf6p10lsDrVhgaqWQoXQRqPeY.js"></script>

FYI: I have also cached my files on the server through Cloudflare

Any help...what am I missing here? Is there a better way to do this, so that my content gets a 24 hours update?


Solution

  • The problem was with the URL and not the code. This feed link has not been updated in a while: timesofindia.indiatimes.com/rssfeeds/913168846.cms

    I figured that out when I tested it with few more RSS feeds and waited for 2 days and those were updated and working fine.

    Static links are also updated once the new content arrives for feed syndication.

    Nothing to do with the CDN script. I guess, it is the script for cache which cloudflare put in.