X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fapi.php;h=b6181ea1a4d0c1252bf58d5e87dad42d8b3f68b5;hb=b4cf27e76731556c2b4d2941f51b74e1935e0ba7;hp=a7853ed32be9445de3023d1bcfdea74c312307f1;hpb=57d888f3e716119488722ee6256ccb5da2492d7d;p=friendica.git diff --git a/include/api.php b/include/api.php index a7853ed32b..b6181ea1a4 100644 --- a/include/api.php +++ b/include/api.php @@ -399,7 +399,7 @@ function api_call(App $a) * * @param string $type Return type (xml, json, rss, as) * @param object $e HTTPException Error object - * @return strin error message formatted as $type + * @return string error message formatted as $type */ function api_error($type, $e) { @@ -946,12 +946,10 @@ function api_create_xml($data, $root_element) * @param string $type Return type (atom, rss, xml, json) * @param array $data JSON style array * - * @return (string|object) XML data or JSON data + * @return (string|object|array) XML data or JSON data */ function api_format_data($root_element, $type, $data) { - $a = get_app(); - switch ($type) { case "atom": case "rss": @@ -1525,8 +1523,7 @@ api_register_func('api/users/search', 'api_users_search'); * @param string $type Return format: json or xml * * @return array|string - * @throws UnauthorizedException - * @throws NotFoundException + * @throws NotFoundException if the results are empty. */ function api_users_lookup($type) { @@ -1558,8 +1555,7 @@ api_register_func('api/users/lookup', 'api_users_lookup', true); * @param string $type Return format: json, xml, atom, rss * * @return array|string - * @throws UnauthorizedException - * @throws BadRequestException + * @throws BadRequestException if the "q" parameter is missing. */ function api_search($type) { @@ -3263,7 +3259,6 @@ api_register_func('api/statuses/followers', 'api_statuses_followers', true); * @param string $type Either "json" or "xml" * * @return boolean|string|array - * @throws UnauthorizedException */ function api_blocks_list($type) { @@ -3285,7 +3280,6 @@ api_register_func('api/blocks/list', 'api_blocks_list', true); * @param string $type Either "json" or "xml" * * @return boolean|string|array - * @throws UnauthorizedException */ function api_friendships_incoming($type) { @@ -5490,6 +5484,37 @@ 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 + */ +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']) + ); + } + + dba::close($terms); + + 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: