diff options
| author | 2016-09-25 15:46:18 +0200 | |
|---|---|---|
| committer | 2016-09-25 15:46:18 +0200 | |
| commit | 74f9aa310d301cbec18040975bdb1b7e03a99b24 (patch) | |
| tree | df64e6bcda6ebc280e9822309ccb5884e68b34ff | |
| parent | 7466f721efd6a9f1d8f5ebbe0007234276c347ee (diff) | |
| parent | e1528845d8827716c11322f15a5f9ce1523fd2d7 (diff) | |
Merge pull request #1263 from Alkarex/more-api-edit
API subscription/quickadd
| -rw-r--r-- | CHANGELOG.md | 2 | ||||
| -rw-r--r-- | p/api/greader.php | 26 |
2 files changed, 25 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c8dbec9b..a1fe033bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## 2016-XX-XX FreshRSS 1.6.0-dev * API - * Support for editing feeds and categories from client applications [#1261](https://github.com/FreshRSS/FreshRSS/pull/1261) + * Support for editing feeds and categories from client applications [#1254](https://github.com/FreshRSS/FreshRSS/issues/1254) * Features * Better control of number of entries per page or RSS feed [#1249](https://github.com/FreshRSS/FreshRSS/issues/1249) * Since X hours: `https://freshrss.example/i/?a=rss&hours=3` diff --git a/p/api/greader.php b/p/api/greader.php index e77ef3726..e2d7dc039 100644 --- a/p/api/greader.php +++ b/p/api/greader.php @@ -361,6 +361,23 @@ function subscriptionEdit($streamNames, $titles, $action, $add = '', $remove = ' exit('OK'); } +function quickadd($url) { + //logMe("quickadd($url)"); + try { + $feed = FreshRSS_feed_Controller::addFeed($url); + exit(json_encode(array( + 'numResults' => 1, + 'streamId' => $feed->id(), + ))); + } catch (Exception $e) { + logMe("subscriptionEdit error subscribe: " . $e->getMessage()); + die(json_encode(array( + 'numResults' => 0, + 'error' => $e->getMessage(), + ))); + } +} + function unreadCount() { //http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/#unread-count //logMe("unreadCount()"); header('Content-Type: application/json; charset=UTF-8'); @@ -531,7 +548,7 @@ function streamContentsItemsIds($streamId, $start_time, $count, $order, $exclude $id = basename($streamId); } elseif (strpos($streamId, 'user/-/label/') === 0) { $type = 'c'; - $c_name = basename($streamId); + $c_name = substr($streamId, 13); $categoryDAO = new FreshRSS_CategoryDAO(); $cat = $categoryDAO->searchByName($c_name); $id = $cat == null ? -1 : $cat->id(); @@ -638,7 +655,7 @@ function markAllAsRead($streamId, $olderThanId) { $f_id = basename($streamId); $entryDAO->markReadFeed($f_id, $olderThanId); } elseif (strpos($streamId, 'user/-/label/') === 0) { - $c_name = basename($streamId); + $c_name = substr($streamId, 13); $categoryDAO = new FreshRSS_CategoryDAO(); $cat = $categoryDAO->searchByName($c_name); $entryDAO->markReadCat($cat === null ? -1 : $cat->id(), $olderThanId); @@ -749,6 +766,11 @@ elseif ($pathInfos[1] === 'reader' && $pathInfos[2] === 'api' && isset($pathInfo subscriptionEdit($streamNames, $titles, $action, $add, $remove); } break; + case 'quickadd': //https://github.com/theoldreader/api + if (isset($_GET['quickadd'])) { + quickadd($_GET['quickadd']); + } + break; } } break; |
