aboutsummaryrefslogtreecommitdiff
path: root/p
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2021-02-06 12:43:30 +0100
committerGravatar GitHub <noreply@github.com> 2021-02-06 12:43:30 +0100
commit4a87f34bcff6afe28e33692e40dcbfb1f663f75a (patch)
treef17fc44db9db6ad3397a4f46dbd4f4ceccb374ac /p
parent8edce0e2095a4e78599bfdd1b39fc778ec29c720 (diff)
API implement OPML import/export (#3424)
#fix https://github.com/FreshRSS/FreshRSS/issues/3421
Diffstat (limited to 'p')
-rw-r--r--p/api/greader.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/p/api/greader.php b/p/api/greader.php
index 5c0e754bd..a1665b952 100644
--- a/p/api/greader.php
+++ b/p/api/greader.php
@@ -270,6 +270,29 @@ function tagList() {
exit();
}
+function subscriptionExport() {
+ $user = Minz_Session::param('currentUser', '_');
+ $export_service = new FreshRSS_Export_Service($user);
+ list($filename, $content) = $export_service->generateOpml();
+ header('Content-Type: application/xml; charset=UTF-8');
+ header('Content-disposition: attachment; filename="' . $filename . '"');
+ echo $content;
+ exit();
+}
+
+function subscriptionImport($opml) {
+ $user = Minz_Session::param('currentUser', '_');
+ $importService = new FreshRSS_Import_Service($user);
+ $ok = $importService->importOpml($opml);
+ if ($ok) {
+ list($nbUpdatedFeeds, $feed, $nbNewArticles) = FreshRSS_feed_Controller::actualizeFeed(0, '', true);
+ invalidateHttpCache($user);
+ exit('OK');
+ } else {
+ badRequest();
+ }
+}
+
function subscriptionList() {
header('Content-Type: application/json; charset=UTF-8');
@@ -1042,6 +1065,14 @@ if ($pathInfos[1] === 'accounts') {
case 'subscription':
if (isset($pathInfos[5])) {
switch ($pathInfos[5]) {
+ case 'export':
+ subscriptionExport();
+ break;
+ case 'import':
+ if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST' && $ORIGINAL_INPUT != '') {
+ subscriptionImport($ORIGINAL_INPUT);
+ }
+ break;
case 'list':
$output = isset($_GET['output']) ? $_GET['output'] : '';
if ($output !== 'json') notImplemented();