try {
        // Check that an access token is present and is valid
        $app->oauth->resource->isValidRequest();
        //get and check the user id by AccessToken
        $app->sfunc->isValidUUID($app, $uuid);
        $outputString = "";
        foreach ($targets as $val) {
            $gBoxEntry = new GiftBox();
            $gBoxEntry->originid = $uuid;
            $gBoxEntry->origintype = isset($inputs['ot']) ? $inputs['ot'] : "0";
            $gBoxEntry->targettype = isset($inputs['tt']) ? $inputs['tt'] : "0";
            if (isset($inputs['co'])) {
                $gBoxEntry->content = $inputs['co'];
            }
            if (isset($inputs['json'])) {
                $gBoxEntry->json = $inputs['json'];
            }
            // example: 2_0_1000
            $gBoxEntry->created_at = $app->sfunc->getGMT();
            $gBoxEntry->expired_at = isset($inputs['expired']) ? $app->sfunc->getGMT($inputs['expired']) : $app->sfunc->getGMT(259200);
            //3 day by default
            $gBoxEntry->targetid = $val;
            $gBoxEntry->save();
            $outputString = $outputString . "," . $gBoxEntry->id;
        }
        $app->sfunc->jsonOutput($app, array('status' => 200, 'giftid' => trim($outputString, ",")));
    } catch (\Exception $e) {
        var_dump($e);
        $app->oauth->catcher($e);
    }
});
        //get and check the user id by AccessToken
        $app->sfunc->isValidUUID($app, $uuid);
        //send a gift to targetgift
        $AGift = new GiftBox();
        $AGift->originid = $uuid;
        $AGift->origintype = 2;
        //niuniu
        $AGift->targetid = $targetPlayer->id;
        $AGift->targettype = 2;
        //niuniu
        $AGift->content = isset($inputs['content']) ? $inputs['content'] : "";
        $AGift->json = $giftContent;
        $AGift->created_at = $app->sfunc->getGMT();
        $AGift->expired_at = isset($inputs['expired']) ? $app->sfunc->getGMT($inputs['expired']) : $app->sfunc->getGMT(259200);
        //3 day by default
        $AGift->save();
        //disable the cashcard
        $card->ownerUUID = -$card->ownerUUID;
        $card->save();
        $app->sfunc->jsonOutput($app, array('status' => 200));
    } catch (\Exception $e) {
        //var_dump($e);
        $app->oauth->catcher($e);
    }
});
$app->post('/resource/niu/nicknamenation/{uuid:[0-9]+}', function ($uuid) use($app) {
    $inputs = $app->sfunc->getContentTypeFromPost();
    //check if parameter is present
    if (!isset($inputs["nation"])) {
        $app->sfunc->badRequest400($app, "NationMissing");
    }