*
* @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)
{
* @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":
* @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)
{
* @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)
{
* @param string $type Either "json" or "xml"
*
* @return boolean|string|array
- * @throws UnauthorizedException
*/
function api_blocks_list($type)
{
* @param string $type Either "json" or "xml"
*
* @return boolean|string|array
- * @throws UnauthorizedException
*/
function api_friendships_incoming($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: