summaryrefslogtreecommitdiff
path: root/classes/api.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-03-24 14:28:43 +0400
committerAndrew Dolgov <[email protected]>2013-03-24 14:28:43 +0400
commitefc6553da498bd16776cf7e88358877b1c088c7f (patch)
treed23e7fd804e9e4c4f131790865c48b120772b8ac /classes/api.php
parent62a1f9899ebfc099720a75a7ff0476c86034d45d (diff)
api: implement subscribeToFeed/unsubscribeFeed (closes #623)
Diffstat (limited to 'classes/api.php')
-rw-r--r--classes/api.php32
1 files changed, 31 insertions, 1 deletions
diff --git a/classes/api.php b/classes/api.php
index 3ec218671..ec1219fe1 100644
--- a/classes/api.php
+++ b/classes/api.php
@@ -2,7 +2,7 @@
class API extends Handler {
- const API_LEVEL = 4;
+ const API_LEVEL = 5;
const STATUS_OK = 0;
const STATUS_ERR = 1;
@@ -666,6 +666,36 @@ class API extends Handler {
return $headlines;
}
+ function unsubscribeFeed() {
+ $feed_id = (int) db_escape_string($this->link, $_REQUEST["feed_id"]);
+
+ $result = db_query($this->link, "SELECT id FROM ttrss_feeds WHERE
+ id = '$feed_id' AND owner_uid = ".$_SESSION["uid"]);
+
+ if (db_num_rows($result) != 0) {
+ Pref_Feeds::remove_feed($this->link, $feed_id, $_SESSION["uid"]);
+ print $this->wrap(self::STATUS_OK, array("status" => "OK"));
+ } else {
+ print $this->wrap(self::STATUS_ERR, array("error" => "FEED_NOT_FOUND"));
+ }
+ }
+
+ function subscribeToFeed() {
+ $feed_url = db_escape_string($this->link, $_REQUEST["feed_url"]);
+ $category_id = (int) db_escape_string($this->link, $_REQUEST["category_id"]);
+ $login = db_escape_string($this->link, $_REQUEST["login"]);
+ $password = db_escape_string($this->link, $_REQUEST["password"]);
+
+ if ($feed_url) {
+ $rc = subscribe_to_feed($this->link, $feed_url, $category_id,
+ $login, $password, false);
+
+ print $this->wrap(self::STATUS_OK, array("status" => $rc));
+ } else {
+ print $this->wrap(self::STATUS_ERR, array("error" => 'INCORRECT_USAGE'));
+ }
+ }
+
}
?>