diff options
| author | 2024-01-10 08:23:45 +0100 | |
|---|---|---|
| committer | 2024-01-10 08:23:45 +0100 | |
| commit | 9c97d8ca729e3cfb067445c0d3c9ad8284132aeb (patch) | |
| tree | 256588d7a65cc8658c808bc7852c816f6ccc1cd2 /app/Controllers/subscriptionController.php | |
| parent | 9a80dde238caf1338b803f67003cd459393efdc3 (diff) | |
JSONFeeds, JSON scraping, and POST requests for feeds (#5662)
* allow POST requests for feeds
* added json dotpath and jsonfeed subscriptions. No translation strings yet
* debug and fix jsonfeed parser
* bugfix params saved when editing feed
* added translations for JSON features
* Update docs for web scraping
* make fix-all
and revert unrelated changes, plus a few manual fixes, but there are still several type errors
* Fix some i18n
* refactor json parsing for both feed types
* cleanup unnecessary comment
* refactored generation of SimplePie for XPath and JSON feeds
* Fix merge error
* Update to newer FreshRSS code
* A bit of refactoring
* doc, whitespace
* JSON Feed is in two words
* Add support for array syntax
* Whitespace
* Add OPML export/import
* Work on i18n
* Accept application/feed+json
* Rework POST
* Fix update
* OPML for cURL options
* Fix types
* Fix Typos
---------
Co-authored-by: Erion Elmasllari <elmasllari@factorsixty.com>
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'app/Controllers/subscriptionController.php')
| -rw-r--r-- | app/Controllers/subscriptionController.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php index 07e0fdcf8..cf23c018e 100644 --- a/app/Controllers/subscriptionController.php +++ b/app/Controllers/subscriptionController.php @@ -143,6 +143,8 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController { $useragent = Minz_Request::paramString('curl_params_useragent'); $proxy_address = Minz_Request::paramString('curl_params'); $proxy_type = Minz_Request::paramString('proxy_type'); + $request_method = Minz_Request::paramString('curl_method'); + $request_fields = Minz_Request::paramString('curl_fields', true); $opts = []; if ($proxy_type !== '') { $opts[CURLOPT_PROXY] = $proxy_address; @@ -163,6 +165,17 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController { if ($useragent !== '') { $opts[CURLOPT_USERAGENT] = $useragent; } + + if ($request_method === 'POST') { + $opts[CURLOPT_POST] = true; + if ($request_fields !== '') { + $opts[CURLOPT_POSTFIELDS] = $request_fields; + if (json_decode($request_fields, true) !== null) { + $opts[CURLOPT_HTTPHEADER] = ['Content-Type: application/json']; + } + } + } + $feed->_attribute('curl_params', empty($opts) ? null : $opts); $feed->_attribute('content_action', Minz_Request::paramString('content_action', true) ?: 'replace'); @@ -224,6 +237,44 @@ class FreshRSS_subscription_Controller extends FreshRSS_ActionController { $xPathSettings['itemUid'] = Minz_Request::paramString('xPathItemUid', true); if (!empty($xPathSettings)) $feed->_attribute('xpath', $xPathSettings); + } elseif ($feed->kind() === FreshRSS_Feed::KIND_JSON_DOTPATH) { + $jsonSettings = []; + if (Minz_Request::paramString('jsonFeedTitle') !== '') { + $jsonSettings['feedTitle'] = Minz_Request::paramString('jsonFeedTitle', true); + } + if (Minz_Request::paramString('jsonItem') !== '') { + $jsonSettings['item'] = Minz_Request::paramString('jsonItem', true); + } + if (Minz_Request::paramString('jsonItemTitle') !== '') { + $jsonSettings['itemTitle'] = Minz_Request::paramString('jsonItemTitle', true); + } + if (Minz_Request::paramString('jsonItemContent') !== '') { + $jsonSettings['itemContent'] = Minz_Request::paramString('jsonItemContent', true); + } + if (Minz_Request::paramString('jsonItemUri') !== '') { + $jsonSettings['itemUri'] = Minz_Request::paramString('jsonItemUri', true); + } + if (Minz_Request::paramString('jsonItemAuthor') !== '') { + $jsonSettings['itemAuthor'] = Minz_Request::paramString('jsonItemAuthor', true); + } + if (Minz_Request::paramString('jsonItemTimestamp') !== '') { + $jsonSettings['itemTimestamp'] = Minz_Request::paramString('jsonItemTimestamp', true); + } + if (Minz_Request::paramString('jsonItemTimeFormat') !== '') { + $jsonSettings['itemTimeFormat'] = Minz_Request::paramString('jsonItemTimeFormat', true); + } + if (Minz_Request::paramString('jsonItemThumbnail') !== '') { + $jsonSettings['itemThumbnail'] = Minz_Request::paramString('jsonItemThumbnail', true); + } + if (Minz_Request::paramString('jsonItemCategories') !== '') { + $jsonSettings['itemCategories'] = Minz_Request::paramString('jsonItemCategories', true); + } + if (Minz_Request::paramString('jsonItemUid') !== '') { + $jsonSettings['itemUid'] = Minz_Request::paramString('jsonItemUid', true); + } + if (!empty($jsonSettings)) { + $feed->_attribute('json_dotpath', $jsonSettings); + } } $feed->_attribute('path_entries_filter', Minz_Request::paramString('path_entries_filter', true)); |
