mirror of
https://github.com/friendica/friendica
synced 2025-04-19 06:30:10 +00:00
API: The command "users/search" is now supported.
This commit is contained in:
parent
0e9c8f6f1a
commit
a333036f00
3 changed files with 42 additions and 6 deletions
|
@ -122,7 +122,6 @@
|
|||
|
||||
// preset
|
||||
$type="json";
|
||||
|
||||
foreach ($API as $p=>$info){
|
||||
if (strpos($a->query_string, $p)===0){
|
||||
$called_api= explode("/",$p);
|
||||
|
@ -936,6 +935,35 @@
|
|||
}
|
||||
api_register_func('api/users/show','api_users_show');
|
||||
|
||||
|
||||
function api_users_search(&$a, $type) {
|
||||
$page = (x($_REQUEST,'page')?$_REQUEST['page']-1:0);
|
||||
|
||||
$userlist = array();
|
||||
|
||||
if (isset($_GET["q"])) {
|
||||
$r = q("SELECT id FROM unique_contacts WHERE name='%s'", dbesc($_GET["q"]));
|
||||
if (!count($r))
|
||||
$r = q("SELECT id FROM unique_contacts WHERE nick='%s'", dbesc($_GET["q"]));
|
||||
|
||||
if (count($r)) {
|
||||
foreach ($r AS $user) {
|
||||
$user_info = api_get_user($a, $user["id"]);
|
||||
//echo print_r($user_info, true)."\n";
|
||||
$userdata = api_apply_template("user", $type, array('user' => $user_info));
|
||||
$userlist[] = $userdata["user"];
|
||||
}
|
||||
$userlist = array("users" => $userlist);
|
||||
} else
|
||||
die(api_error($a, $type, t("User not found.")));
|
||||
} else
|
||||
die(api_error($a, $type, t("User not found.")));
|
||||
|
||||
return ($userlist);
|
||||
}
|
||||
|
||||
api_register_func('api/users/search','api_users_search');
|
||||
|
||||
/**
|
||||
*
|
||||
* http://developer.twitter.com/doc/get/statuses/home_timeline
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue