-
-
Notifications
You must be signed in to change notification settings - Fork 140
Expand file tree
/
Copy pathexample-json.php
More file actions
27 lines (19 loc) · 819 Bytes
/
example-json.php
File metadata and controls
27 lines (19 loc) · 819 Bytes
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
<?php
header('Content-Type: text/html; charset=utf-8');
if (!ini_get('date.timezone')) {
date_default_timezone_set('Europe/Prague');
}
require_once 'src/Feed.php';
$json = Feed::loadJsonfeed('https://www.jsonfeed.org/feed.json');
?>
<h1><?php echo htmlspecialchars($json->title) ?></h1>
<p><i><?php if(isset($json->description)){ echo htmlspecialchars($json->description); } ?></i></p>
<?php foreach ($json->items as $item): ?>
<h2><a href="<?php echo htmlspecialchars($item->url) ?>"><?php echo htmlspecialchars($item->title) ?></a>
<small><?php echo date('j.n.Y H:i', (int) $item->timestamp) ?></small></h2>
<?php if (isset($item->content_html)): ?>
<div><?php echo $item->content_html ?></div>
<?php else: ?>
<p><?php echo htmlspecialchars($item->summary) ?></p>
<?php endif ?>
<?php endforeach ?>