From 9eb5a976b03fae6bd1e1fce6abfe4a6c7964d1ae Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 24 Jun 2010 18:11:50 -0700 Subject: [PATCH] Have API methods for search subclass ApiPrivateAuthAction --- actions/{twitapisearchatom.php => apisearchatom.php} | 12 +++++++++--- actions/{twitapisearchjson.php => apisearchjson.php} | 7 +++++-- actions/{twitapitrends.php => apitrends.php} | 8 +++++--- lib/router.php | 6 +++--- 4 files changed, 22 insertions(+), 11 deletions(-) rename actions/{twitapisearchatom.php => apisearchatom.php} (97%) rename actions/{twitapisearchjson.php => apisearchjson.php} (94%) rename actions/{twitapitrends.php => apitrends.php} (93%) diff --git a/actions/twitapisearchatom.php b/actions/apisearchatom.php similarity index 97% rename from actions/twitapisearchatom.php rename to actions/apisearchatom.php index 51e8a8881b..60bb8b0408 100644 --- a/actions/twitapisearchatom.php +++ b/actions/apisearchatom.php @@ -22,7 +22,7 @@ * @category Search * @package StatusNet * @author Zach Copley - * @copyright 2008-2009 StatusNet, Inc. + * @copyright 2008-2010 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ @@ -31,6 +31,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } +require_once INSTALLDIR.'/lib/apiprivateauth.php'; + /** * Action for outputting search results in Twitter compatible Atom * format. @@ -44,10 +46,10 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ * - * @see ApiAction + * @see ApiPrivateAuthAction */ -class TwitapisearchatomAction extends ApiAction +class ApiSearchAtomAction extends ApiPrivateAuthAction { var $cnt; @@ -96,8 +98,11 @@ class TwitapisearchatomAction extends ApiAction function prepare($args) { + common_debug("in apisearchatom prepare()"); + parent::prepare($args); + $this->query = $this->trimmed('q'); $this->lang = $this->trimmed('lang'); $this->rpp = $this->trimmed('rpp'); @@ -138,6 +143,7 @@ class TwitapisearchatomAction extends ApiAction function handle($args) { parent::handle($args); + common_debug("In apisearchatom handle()"); $this->showAtom(); } diff --git a/actions/twitapisearchjson.php b/actions/apisearchjson.php similarity index 94% rename from actions/twitapisearchjson.php rename to actions/apisearchjson.php index b5c006aa7b..e44634684d 100644 --- a/actions/twitapisearchjson.php +++ b/actions/apisearchjson.php @@ -22,7 +22,7 @@ * @category Search * @package StatusNet * @author Zach Copley - * @copyright 2008-2009 StatusNet, Inc. + * @copyright 2008-2010 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ @@ -31,6 +31,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } +require_once INSTALLDIR.'/lib/apiprivateauth.php'; require_once INSTALLDIR.'/lib/jsonsearchresultslist.php'; /** @@ -44,7 +45,7 @@ require_once INSTALLDIR.'/lib/jsonsearchresultslist.php'; * @see ApiAction */ -class TwitapisearchjsonAction extends ApiAction +class ApiSearchJSONAction extends ApiPrivateAuthAction { var $query; var $lang; @@ -64,6 +65,8 @@ class TwitapisearchjsonAction extends ApiAction function prepare($args) { + common_debug("apisearchjson prepare()"); + parent::prepare($args); $this->query = $this->trimmed('q'); diff --git a/actions/twitapitrends.php b/actions/apitrends.php similarity index 93% rename from actions/twitapitrends.php rename to actions/apitrends.php index 5a04569a22..5b74636c69 100644 --- a/actions/twitapitrends.php +++ b/actions/apitrends.php @@ -22,7 +22,7 @@ * @category Search * @package StatusNet * @author Zach Copley - * @copyright 2008-2009 StatusNet, Inc. + * @copyright 2008-2010 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ @@ -31,6 +31,8 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } +require_once INSTALLDIR.'/lib/apiprivateauth.php'; + /** * Returns the top ten queries that are currently trending * @@ -43,7 +45,7 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { * @see ApiAction */ -class TwitapitrendsAction extends ApiAction +class ApiTrendsAction extends ApiPrivateAuthAction { var $callback; @@ -82,7 +84,7 @@ class TwitapitrendsAction extends ApiAction */ function showTrends() { - $this->serverError(_('API method under construction.'), $code = 501); + $this->serverError(_('API method under construction.'), 501); } } \ No newline at end of file diff --git a/lib/router.php b/lib/router.php index fec229c9b6..7e1e6a2a47 100644 --- a/lib/router.php +++ b/lib/router.php @@ -667,9 +667,9 @@ class Router ); // search - $m->connect('api/search.atom', array('action' => 'twitapisearchatom')); - $m->connect('api/search.json', array('action' => 'twitapisearchjson')); - $m->connect('api/trends.json', array('action' => 'twitapitrends')); + $m->connect('api/search.atom', array('action' => 'ApiSearchAtom')); + $m->connect('api/search.json', array('action' => 'ApiSearchJSON')); + $m->connect('api/trends.json', array('action' => 'ApiTrends')); $m->connect('api/oauth/request_token', array('action' => 'apioauthrequesttoken')); -- 2.39.5