Browse Source

Add option to get user info by ID, not name

tags/1.0beta
Skylar Ittner 3 years ago
parent
commit
0e13f77e05
1 changed files with 16 additions and 4 deletions
  1. +16
    -4
      api.php

+ 16
- 4
api.php View File

@@ -49,11 +49,23 @@ switch ($VARS['action']) {
}
break;
case "userinfo":
if (user_exists($VARS['username'])) {
$data = $database->select("accounts", ["uid", "realname (name)", "email", "phone" => ["phone1 (1)", "phone2 (2)"]], ["username" => $VARS['username']])[0];
exit(json_encode(["status" => "OK", "data" => $data]));
if (!is_empty($VARS['username'])) {
if (user_exists($VARS['username'])) {
$data = $database->select("accounts", ["uid", "username", "realname (name)", "email", "phone" => ["phone1 (1)", "phone2 (2)"]], ["username" => $VARS['username']])[0];
exit(json_encode(["status" => "OK", "data" => $data]));
} else {
exit(json_encode(["status" => "ERROR", "msg" => lang("login incorrect", false)]));
}
} else if (!is_empty($VARS['uid'])) {
if ($database->has('accounts', ['uid' => $VARS['uid']])) {
$data = $database->select("accounts", ["uid", "username", "realname (name)", "email", "phone" => ["phone1 (1)", "phone2 (2)"]], ["uid" => $VARS['uid']])[0];
exit(json_encode(["status" => "OK", "data" => $data]));
} else {
exit(json_encode(["status" => "ERROR", "msg" => lang("login incorrect", false)]));
}
} else {
exit(json_encode(["status" => "ERROR", "msg" => lang("login incorrect", false)]));
header("HTTP/1.1 400 Bad Request");
die("\"400 Bad Request\"");
}
break;
case "userexists":


Loading…
Cancel
Save