Exemplo n.º 1
0
 public function output_wtkn($response = array(), $statusHeader = 200)
 {
     $statusHeader = empty($statusHeader) ? 200 : $statusHeader;
     if (!is_numeric($statusHeader)) {
         show_error('Status codes must be numeric', 500);
     }
     $response = is_array($response) ? $response : array($response);
     // CREATE TOKEN
     try {
         $token = $this->jwt->createToken($GLOBALS['identifier']);
     } catch (Exception $e) {
         Rest::output(['error' => $e->getMessage()], 500);
     }
     header("HTTP/1.0 {$statusHeader}");
     header('Content-Type: application/json');
     echo json_encode(array_merge(['status' => $statusHeader], ['Token-Key' => $token], $response));
     exit;
 }