-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjsonfeed.php
36 lines (31 loc) · 994 Bytes
/
jsonfeed.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
<?php
$configs = include('configs.php');
$results = file_get_contents('text.txt');
$feed_items = array();
$wp_comments = eval("return " . $results . ";");
$i=0;
foreach ($wp_comments as $livepost){
if($i==20) break;
$feed_item = array(
'id' => $livepost['comment_ID'],
'url' => $configs->siteUrl.'#'.$livepost['comment_ID'],
'content_text' => $livepost['comment_content'],
'date_published' => date( DATE_RFC822, strtotime($livepost['comment_date']) ),
'author' => array(
'name' => $configs->userName,
),
);
$feed_items[] = $feed_item;
$i++;
}
$feed_json = array(
'version' => 'https://jsonfeed.org/version/1',
'home_page_url' => $configs->siteUrl,
'feed_url' => $configs->siteUrl.'/jsonfeed.php',
'title' => $configs->siteTitle,
'description' => $configs->siteDescription,
'items' => $feed_items,
);
header('Content-Type: application/json; charset=utf-8');
echo json_encode($feed_json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
?>