fixes for R-J feed
This commit is contained in:
22
fullrss.php
22
fullrss.php
@@ -40,12 +40,14 @@
|
|||||||
|
|
||||||
$url=$_GET["url"];
|
$url=$_GET["url"];
|
||||||
$feed=new SimpleXmlElement(file_get_contents($url)); // read feed into object
|
$feed=new SimpleXmlElement(file_get_contents($url)); // read feed into object
|
||||||
|
|
||||||
|
// type 1
|
||||||
foreach ($feed->item as $entry) // fix up each entry
|
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);
|
$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
|
$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_HTTPHEADER, array("x-api-key: ".$mercury_api_key));
|
||||||
@@ -56,6 +58,22 @@
|
|||||||
$entry->description=$article->content;
|
$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");
|
header("Content-Type: application/rss+xml");
|
||||||
echo $feed->asXML(); // write the modified feed back out
|
echo $feed->asXML(); // write the modified feed back out
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user