aboutsummaryrefslogtreecommitdiff
path: root/p/api
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2016-09-25 00:14:36 +0200
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2016-09-25 00:14:36 +0200
commit71b98a0ffc41ea869e8c49c2889cda5b3e113030 (patch)
tree39762e93dfce1898ebcbbd12ea50086514a38f4a /p/api
parent324c83348ca44f3c13f4e0efeea25bbc96ed3b05 (diff)
API add feed
Diffstat (limited to 'p/api')
-rw-r--r--p/api/greader.php20
1 files changed, 14 insertions, 6 deletions
diff --git a/p/api/greader.php b/p/api/greader.php
index 131eb65c5..dc8dd92bc 100644
--- a/p/api/greader.php
+++ b/p/api/greader.php
@@ -298,18 +298,22 @@ function subscriptionEdit($streamNames, $titles, $action, $add = '', $remove = '
if ($add != '' || $remove != '') {
$categoryDAO = new FreshRSS_CategoryDAO();
}
+ $c_name = '';
if ($add != '' && strpos($add, 'user/-/label/') === 0) { //user/-/label/Example
- $c_name = basename($add);
+ $c_name = substr($add, 13);
$cat = $categoryDAO->searchByName($c_name);
$addCatId = $cat == null ? -1 : $cat->id();
} else if ($remove != '' && strpos($remove, 'user/-/label/')) {
$addCatId = 1; //Default category
}
+ if ($addCatId <= 0 && $c_name = '') {
+ $addCatId = 1; //Default category
+ }
$feedDAO = FreshRSS_Factory::createFeedDao();
for ($i = count($streamNames) - 1; $i >= 0; $i--) {
$streamName = $streamNames[$i]; //feed/http://example.net/sample.xml ; feed/338
if (strpos($streamName, 'feed/') === 0) {
- $streamName = basename($streamName);
+ $streamName = substr($streamName, 5);
$feedId = 0;
if (ctype_digit($streamName)) {
if ($action === 'subscribe') {
@@ -324,11 +328,15 @@ function subscriptionEdit($streamNames, $titles, $action, $add = '', $remove = '
switch ($action) {
case 'subscribe':
if ($feedId <= 0) {
- //TODO
- notImplemented();
- } else {
- badRequest();
+ $http_auth = ''; //TODO
+ try {
+ $feed = FreshRSS_feed_Controller::addFeed($streamName, $title, $addCatId, $c_name, $http_auth);
+ continue;
+ } catch (Exception $e) {
+ logMe("subscriptionEdit error subscribe: " . $e->getMessage());
+ }
}
+ badRequest();
break;
case 'unsubscribe':
if (!($feedId > 0 && FreshRSS_feed_Controller::deleteFeed($feedId))) {