Add name/bio updating API

master
Skylar Ittner 5 years ago
parent 8b349fd0ea
commit f21a8baa1e

@ -0,0 +1,27 @@
<?php
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
$profile = $database->get("accounts", ["[>]authkeys" => ["accountid"]], ["accounts.accountid","name", "bio"], ["key" => $VARS["key"]]);
if (!empty($VARS["name"])) {
if (strlen($VARS["name"]) > 200) {
sendJsonResp($Strings->get("Name is too long (max 200 characters)."), "ERROR");
}
$profile["name"] = htmlentities($VARS["name"]);
}
if (!empty($VARS["bio"])) {
$profile["bio"] = htmlentities($VARS["bio"]);
}
$database->update("accounts", [
"name" => $profile["name"],
"bio" => $profile["bio"],
], ["accountid" => $profile["accountid"]]);
sendJsonResp();

@ -66,6 +66,14 @@ $APIS = [
"id (optional)" => "/[0-9a-z]+/"
]
],
"setprofile" => [
"load" => "setprofile.php",
"vars" => [
"key" => $keyregex,
"name (optional)" => "string",
"bio (optional)" => "string"
]
],
"getnearby" => [
"load" => "nearby.php",
"vars" => [

Loading…
Cancel
Save