-
Notifications
You must be signed in to change notification settings - Fork 0
/
rss_agg.php
executable file
·58 lines (45 loc) · 1.33 KB
/
rss_agg.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
//Naslovi RSS feedov, ki bodo vključeni
$ra_strani = array(
'http://med.over.net/feed/',
'http://travel.over.net/feed/',
'http://style.over.net/feed/'
);
require_once('autoloader.php'); //Naloži SimplePie
$feed = new SimplePie();
$feed->set_feed_url( $ra_strani );
$feed->init();
//$feed->handle_content_type();
$file = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><rss version=\"2.0\" >
<channel>
<title>RSS Over.net</title>
<description>Združeni RSS feedi Over.net</description>
<link>http://med.over.net</link>
<lastBuildDate>" . date('r', time()) . "</lastBuildDate>
<pubDate>" . date('r', time()) . "</pubDate>
<language>sl-SI</language>
";
foreach ($feed->get_items() as $item):
$file .= "
<item>
<title>" . $item->get_title() . "</title>";
foreach ($item->get_categories() as $category)
{
$file .= "\n\t\t<category><![CDATA[" . $category->get_label() . "]]></category>";
}
$file .= "
<description><![CDATA[" . $item->get_description() . "]]></description>
<link>" . $item->get_permalink() . "</link>
<guid isPermaLink=\"false\">" . $item->get_permalink() . "</guid>
<pubDate>" . $item->get_date() . "</pubDate>
</item>
";
endforeach;
$file .= "
</channel>
</rss>";
// Izpiši kodo v brskalnik
echo $file;
//Izpiši kodo v datoteko "index.rss"
//file_put_contents("index.rss", $file);
?>