<?php
header("Content-Type: application/xml; charset=UTF-8");

$BASE = "https://www.vandrive.gr";
$API  = $BASE . "/app/api";

$items = json_decode(file_get_contents($API."/posts?limit=50"), true);
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>

<rss version="2.0"
 xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">

<channel>
<title>VanDrive News</title>
<link><?= $BASE ?>/blog/</link>
<description>Ενοικίαση βαν στη Βέροια</description>

<?php foreach ($items as $p): 
  $url = $BASE."/blog/".$p['slug'];
?>
<item>
  <title><?= htmlspecialchars($p['title']) ?></title>
  <link><?= $url ?></link>
  <pubDate><?= date(DATE_RSS, strtotime($p['created_at'])) ?></pubDate>

  <news:news>
	<news:publication>
	  <news:name>VanDrive</news:name>
	  <news:language>el</news:language>
	</news:publication>
	<news:publication_date><?= date("c", strtotime($p['created_at'])) ?></news:publication_date>
	<news:title><?= htmlspecialchars($p['title']) ?></news:title>
  </news:news>

</item>
<?php endforeach; ?>

</channel>
</rss>