'invalid_grant', 'error_description' => 'The authorization code is invalid or expired.' ))); } public static function invalidHeader() { http_response_code(400); die(json_encode(array( 'error' => 'invalid_header', 'error_description' => 'The request is missing the Authorization header or the Authorization header is invalid.' ))); } public static function invalidRequest() { http_response_code(400); die(json_encode(array( 'error' => 'invalid_request', 'error_description' => 'The request is missing a parameter, uses an unsupported parameter, uses an invalid parameter or repeats a parameter.' ))); } public static function invalidCredential() { http_response_code(400); die(json_encode(array( 'error' => 'invalid_credential', 'error_description' => 'The request has error(s) in the credentials gave.' ))); } public static function internalError() { http_response_code(500); die(); } } switch ($pathInfo[0] . $_SERVER['REQUEST_METHOD']) { case 'match' . 'GET' : $matchid = $_GET['id']; $matchScore = $db->getMatchScore($matchid); if ($matchScore != NULL){ http_response_code(200); die(json_encode($matchScore)); }else{ APIErrors::internalError(); } case 'matchs' . 'GET' : if (empty($_GET['sport_id'])){ $matchs = $db->getAllMatches(); if ($matchs != NULL){ http_response_code(200); die(json_encode($matchs)); }else{ APIErrors::internalError();} }else{ $matchs = $db->getAllMatchesSport($_GET['sport_id']); if ($matchs != NULL){ http_response_code(200); die(json_encode($matchs)); }else{ APIErrors::internalError();} } case 'test' . 'GET' : default: http_response_code(404); die(); } ?>