function ValidateToken() { try { $headers = getallheaders(); if (!isset($headers['Authorization'])) { return; } $tokenObject = explode(' ', $headers['Authorization']); if (count($tokenObject) != 2) { return; } $tokenValue = $tokenObject[1]; if ($tokenValue == NULL || $tokenValue == '') { return; } JWT::$leeway = 60 * 60 * 24; //24 hours $decoded = JWT::decode($tokenValue, "JWT_KEY", array('HS256')); if (empty($decoded)) { return; } $decoded_array = (array) $decoded; if (empty($decoded_array)) { return; } self::$token = $tokenValue; self::$userId = $decoded_array['uid']; self::$isAuthorized = TRUE; } catch (UnexpectedValueException $e) { return; } catch (Exception $e) { return; } }
function __construct() { parent::__construct(); }
function availability_post() { parent::ValidateToken(); $appSettings = self::get_app_settings(); $user = self::get_user(self::$userId); $entityBody = file_get_contents('php://input'); $availability = self::get_doctors_available($entityBody); $processor = new \FacebookProcessor\Processor(APP_ID_FOR_ADS_MANAGER, APP_SECRET_FOR_ADS_MANAGER, $user->fb_token, $appSettings, $availability); $processor->save_log('trace', 'Manual process request'); $processor->Process(); $this->response(null, self::HTTP_OK); }