From cc35094bb261cb3185def89d745317fa756560ee Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 3 Jun 2025 00:16:17 +0200 Subject: Add API endpoint for extensions (#7576) * Add API endpoint for extensions Useful for https://github.com/FreshRSS/FreshRSS/issues/7572 * Support PATH_INFO Now also support being invoked like `/api/misc.php/Extension%20Name/` * More documentation --- p/api/index.php | 14 +++++++----- p/api/misc.php | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 p/api/misc.php (limited to 'p/api') diff --git a/p/api/index.php b/p/api/index.php index 66c9e465c..fd9828080 100644 --- a/p/api/index.php +++ b/p/api/index.php @@ -28,9 +28,7 @@ echo json_encode([

Google Reader compatible API

Your API address:
-
+
Google Reader API configuration test:
?
@@ -38,12 +36,16 @@ echo Minz_Url::display('/api/greader.php', 'html', true);

Fever compatible API

Your API address:
-
+
Fever API configuration test:
?
+

API for extensions

+
+
Your API address:
+
+
+ diff --git a/p/api/misc.php b/p/api/misc.php new file mode 100644 index 000000000..7724caa7a --- /dev/null +++ b/p/api/misc.php @@ -0,0 +1,68 @@ + 1) { + $extensionName = $pathInfos[1]; + } + } +} + +if ($extensionName === '') { + badRequest(); +} + +Minz_Session::init('FreshRSS', volatile: true); + +FreshRSS_Context::initSystem(); +if ( + !FreshRSS_Context::hasSystemConf() || + !FreshRSS_Context::systemConf()->api_enabled || + empty(FreshRSS_Context::systemConf()->extensions_enabled[$extensionName]) +) { + serviceUnavailable(); +} + +// Only enable the extension that is being called +FreshRSS_Context::systemConf()->extensions_enabled = [$extensionName => true]; +Minz_ExtensionManager::init(); + +Minz_Translate::init(); + +if (!Minz_ExtensionManager::callHookUnique('api_misc')) { + serviceUnavailable(); +} -- cgit v1.2.3