}
        $chatLog->save();
        $app->sfunc->jsonOutput($app, array('status' => 200, 'logid' => $chatLog->id));
    } catch (\Exception $e) {
        var_dump($e);
        $app->oauth->catcher($e);
    }
});
// for any user to grab his/her own non-expired gift partial list
$app->get('/resource/niugift/{uuid:[0-9]+}/{startid:[0-9]+}', function ($uuid, $startid) use($app) {
    try {
        // Check that an access token is present and is valid
        $app->oauth->resource->isValidRequest();
        $thisTime = "'" . $app->sfunc->getGMT() . "'";
        // use ' to quote the time string
        $gBoxEntries = GiftBox::find(array("conditions" => "id>{$startid} AND targetid={$uuid} AND expired_at>{$thisTime}", "columns" => "id,originid as og, origintype as ot,content as co,json", "limit" => "10", "order" => "created_at DESC"));
        if ($gBoxEntries == true) {
            $logArray = $gBoxEntries->toArray();
            if (count($logArray) > 0) {
                $app->sfunc->jsonOutput($app, array('status' => 200, 'gift' => $logArray));
            } else {
                $app->sfunc->notModified304($app);
            }
        } else {
            $app->sfunc->forbidden403($app);
        }
    } catch (\Exception $e) {
        var_dump($e);
        $app->oauth->catcher($e);
    }
});