]> git.mxchange.org Git - friendica.git/commitdiff
Implement saved_searches/list API
authorPierre Rudloff <contact@rudloff.pro>
Tue, 19 Dec 2017 13:20:32 +0000 (14:20 +0100)
committerPierre Rudloff <contact@rudloff.pro>
Tue, 19 Dec 2017 13:22:38 +0000 (14:22 +0100)
doc/api.md
include/api.php

index d756e81a401e3948edbd4d1640eb724c53506941..3a2740764ae0e1b64b2722b8c6ba45f3833202c9 100644 (file)
@@ -615,6 +615,12 @@ This is an alias for `search`.
 
 ---
 
+### saved_searches/list (*; AUTH)
+
+This call does not have any parameter.
+
+---
+
 ### users/search (*)
 
 #### Parameters
@@ -1234,7 +1240,6 @@ The following API calls from the Twitter API are not implemented in either Frien
 * lists/subscriptions
 * lists/members/destroy_all
 * lists/ownerships
-* saved_searches/list
 * saved_searches/show/:id
 * saved_searches/create
 * saved_searches/destroy/:id
index a7853ed32be9445de3023d1bcfdea74c312307f1..659f23b58cda523e010c9ced35c4cf067baee37d 100644 (file)
@@ -5490,6 +5490,36 @@ function api_friendica_profile_show($type)
 }
 api_register_func('api/friendica/profile/show', 'api_friendica_profile_show', true, API_METHOD_GET);
 
+/**
+ * Returns a list of saved searches.
+ *
+ * @see https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-saved_searches-list
+ *
+ * @param  string $type Return format: json or xml
+ *
+ * @return string|array
+ * @throws UnauthorizedException
+ */
+function api_saved_searches_list($type)
+{
+       $terms = dba::select('search', array('id', 'term'), array('uid' => local_user()));
+
+       $result = array();
+       while ($term = $terms->fetch()) {
+               $result[] = array(
+                       'name' => $term['term'],
+                       'query' => $term['term'],
+                       'id_str' => $term['id'],
+                       'id' => intval($term['id'])
+               );
+       }
+
+       return api_format_data("terms", $type, array('terms' => $result));
+}
+
+/// @TODO move to top of file or somwhere better
+api_register_func('api/saved_searches/list', 'api_saved_searches_list', true);
+
 /*
 @TODO Maybe open to implement?
 To.Do: