fixes for R-J feed

This commit is contained in:
2019-01-08 22:56:16 -08:00
parent 1b2cb9a5b6
commit 0f3e8d3b14

View File

@@ -40,12 +40,14 @@
$url=$_GET["url"];
$feed=new SimpleXmlElement(file_get_contents($url)); // read feed into object
// type 1
foreach ($feed->item as $entry) // fix up each entry
{
if (strpos($entry->link, "http://minx.cc/?post=")==0) // fix AoSHQ links
if (substr($entry->link, 0, 21)=="http://minx.cc/?post=") // fix AoSHQ links
$entry->link="http://minx.cc:1080/?post=".substr($entry->link, 21);
if ($max_age==0 || time()-strtotime($entry->children("dc", TRUE)->date)<$max_age)
if ($max_age==0 || time()-strtotime($entry->children("dc", TRUE)->date)<$max_age || time()-strtotime($entry->pubDate)<$max_age)
{
$ch=curl_init(); // use Mercury to get article text
curl_setopt($ch, CURLOPT_HTTPHEADER, array("x-api-key: ".$mercury_api_key));
@@ -56,6 +58,22 @@
$entry->description=$article->content;
}
}
// type 2
foreach ($feed->channel->item as $entry) // fix up each entry
{
if ($max_age==0 || time()-strtotime($entry->pubDate)<$max_age || time()-strtotime($entry->pubDate)<$max_age)
{
$ch=curl_init(); // use Mercury to get article text
curl_setopt($ch, CURLOPT_HTTPHEADER, array("x-api-key: ".$mercury_api_key));
curl_setopt($ch, CURLOPT_URL, "https://mercury.postlight.com/parser?url=".$entry->link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$article=json_decode(curl_exec($ch));
curl_close($ch);
$entry->description=$article->content;
}
}
header("Content-Type: application/rss+xml");
echo $feed->asXML(); // write the modified feed back out
?>