File "api-token.inc.php"
Full Path: /srv/www/www.cadoro.it/src/controllers/api-token.inc.php
File size: 1.06 KB
MIME-type: text/x-php
Charset: utf-8
<?php
header('Access-Control-Allow-Origin: *');
header('Content-Type: text/json; charset="UTF-8"');
# POST
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$data = _json(file_get_contents('php://input'));
$user->update_app(array(
"app_token" => _a($data, 'app_token', $user['app_token']),
"app_notifications" => _a($data, 'app_notifications', $user['app_notifications']),
"app_details" => $data,
));
if (!_a($user['data'], 'first-app')) {
$res = classes\Fidelity::SetPunti($user['card'], '04');
if (!_a($res, 'Errore') || $res['Errore'] == 3 || $res['Errore'] == 6) {
$user['data']['first-app'] = date('Y-m-d H:i:s');
$user->update_data($user['data']);
}
}
$user = models\User::get_by_id($user['id']);
$result = array("user" => $user);
# JSON output
echo json_encode($result);
}
# DEFAULT
else {
header('HTTP/1.0 400 Bad Request', true, 400);
header("Content-Type: application/json; charset=utf-8");
echo json_encode(array("error" => "unsupported method"));
}
?>