-
Notifications
You must be signed in to change notification settings - Fork 131
/
feed.php
46 lines (35 loc) · 1.18 KB
/
feed.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
<?php
require 'common.php';
require 'vendor/PicoTools/Helper.php';
require 'vendor/PicoFarad/Response.php';
require 'vendor/PicoFarad/Request.php';
require 'vendor/PicoFeed/Writers/Atom.php';
use PicoFarad\Response;
use PicoFarad\Request;
use PicoFeed\Writers\Atom;
// Check token
$feed_token = Model\get_config_value('feed_token');
$request_token = Request\param('token');
if ($feed_token !== $request_token) {
Response\text('Access Forbidden', 403);
}
// Load translations
$language = Model\get_config_value('language') ?: 'en_US';
if ($language !== 'en_US') PicoTools\Translator\load($language);
// Build Feed
$writer = new Atom;
$writer->title = t('Bookmarks').' - Miniflux';
$writer->site_url = Helper\get_current_base_url();
$writer->feed_url = $writer->site_url.'feed.php?token='.urlencode($feed_token);
$bookmarks = Model\get_bookmarks();
foreach ($bookmarks as $bookmark) {
$article = Model\get_item($bookmark['id']);
$writer->items[] = array(
'id' => $article['id'],
'title' => $article['title'],
'updated' => $article['updated'],
'url' => $article['url'],
'content' => $article['content'],
);
}
Response\xml($writer->execute());