Stubs for Twitter-compatible API search methods

This commit is contained in:
Zach Copley 2009-03-04 18:14:52 -08:00
parent 344f7194f0
commit 38b6946349
3 changed files with 202 additions and 5 deletions

97
actions/twitapisearch.php Normal file
View File

@ -0,0 +1,97 @@
<?php
/**
* Laconica, the distributed open-source microblogging tool
*
* List of replies
*
* PHP version 5
*
* LICENCE: This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Search
* @package Laconica
* @author Zach Copley <zach@controlyourself.ca>
* @copyright 2008-2009 Control Yourself, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://laconi.ca/
*/
if (!defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR.'/lib/twitterapi.php';
/**
* Action handler for Twitter-compatible API search
*
* @category Search
* @package Laconica
* @author Zach Copley <zach@controlyourself.ca>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://laconi.ca/
* @see TwitterapiAction
*/
class TwitapisearchAction extends TwitterapiAction
{
var $query;
var $limit;
var $callback;
/**
* Initialization.
*
* @param array $args Web and URL arguments
*
* @return boolean false if user doesn't exist
*/
function prepare($args)
{
parent::prepare($args);
$qeury = $this->trimmed('query');
return true;
}
/**
* Handle a request
*
* @param array $args Arguments from $_REQUEST
*
* @return void
*/
function handle($args)
{
parent::handle($args);
$this->showResults($this->limit);
}
/**
* Show search results
*
* @param int $limit Number of notices to show
*
* @return void
*/
function showResults($limit)
{
$this->serverError(_('API method under construction.'), $code = 501);
}
}

90
actions/twitapitrends.php Normal file
View File

@ -0,0 +1,90 @@
<?php
/**
* Laconica, the distributed open-source microblogging tool
*
* List of replies
*
* PHP version 5
*
* LICENCE: This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @category Search
* @package Laconica
* @author Zach Copley <zach@controlyourself.ca>
* @copyright 2008-2009 Control Yourself, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://laconi.ca/
*/
if (!defined('LACONICA')) {
exit(1);
}
require_once INSTALLDIR.'/lib/twitterapi.php';
/**
* Returns the top ten queries that are currently trending
*
* @category Search
* @package Laconica
* @author Zach Copley <zach@controlyourself.ca>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://laconi.ca/
*
* @see TwitterapiAction
*/
class TwitapitrendsAction extends TwitterapiAction
{
var $callback;
/**
* Initialization.
*
* @param array $args Web and URL arguments
*
* @return boolean false if user doesn't exist
*/
function prepare($args)
{
parent::prepare($args);
return true;
}
/**
* Handle a request
*
* @param array $args Arguments from $_REQUEST
*
* @return void
*/
function handle($args)
{
parent::handle($args);
$this->showTrends();
}
/**
* Output the trends
*
* @return void
*/
function showTrends()
{
$this->serverError(_('API method under construction.'), $code = 501);
}
}

View File

@ -230,7 +230,7 @@ class Router
$m->connect('api/users/:method/:argument', $m->connect('api/users/:method/:argument',
array('action' => 'api', array('action' => 'api',
'apiaction' => 'users'), 'apiaction' => 'users'),
array('method' => 'show(\.(xml|json))?')); array('method' => 'show(\.(xml|json))?'));
$m->connect('api/users/:method', $m->connect('api/users/:method',
@ -284,14 +284,14 @@ class Router
array('action' => 'api', array('action' => 'api',
'apiaction' => 'statuses', 'apiaction' => 'statuses',
'method' => 'friendsIDs')); 'method' => 'friendsIDs'));
foreach (array('xml', 'json') as $e) { foreach (array('xml', 'json') as $e) {
$m->connect('api/friends/ids.'.$e, $m->connect('api/friends/ids.'.$e,
array('action' => 'api', array('action' => 'api',
'apiaction' => 'statuses', 'apiaction' => 'statuses',
'method' => 'friendsIDs.'.$e)); 'method' => 'friendsIDs.'.$e));
} }
$m->connect('api/followers/ids/:argument', $m->connect('api/followers/ids/:argument',
array('action' => 'api', array('action' => 'api',
'apiaction' => 'statuses', 'apiaction' => 'statuses',
@ -305,11 +305,11 @@ class Router
} }
// account // account
$m->connect('api/account/:method', $m->connect('api/account/:method',
array('action' => 'api', array('action' => 'api',
'apiaction' => 'account')); 'apiaction' => 'account'));
// favorites // favorites
$m->connect('api/favorites/:method/:argument', $m->connect('api/favorites/:method/:argument',
@ -352,6 +352,16 @@ class Router
array('action' => 'api', array('action' => 'api',
'apiaction' => 'laconica')); 'apiaction' => 'laconica'));
// search
foreach (array('json', 'atom') as $e) {
$m->connect('api/search.'.$e,
array('action' => 'twitapisearch'));
}
$m->connect('api/trends.json', array('action' => 'twitapitrends'));
// user stuff // user stuff
foreach (array('subscriptions', 'subscribers', foreach (array('subscriptions', 'subscribers',