Created
April 21, 2018 06:25
-
-
Save kantapp/e4dfabc840ef06ccf615a1725ff6be76 to your computer and use it in GitHub Desktop.
How to get Header in php using Slim Framework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use \Psr\Http\Message\ServerRequestInterface as Request; | |
use \Psr\Http\Message\ResponseInterface as Response; | |
require 'vendor/autoload.php'; | |
$app = new \Slim\App; | |
$app->get('/',function($request,$response,$array) | |
{ | |
// $headers = apache_request_headers(); | |
// if (isset($headers['Authorization'])) | |
// { | |
// $api_key = $headers['Authorization']; | |
// echo $api_key; | |
// } else { | |
// $data["error"] = true; | |
// $data["message"] = "Api key is misssing"; | |
// return $response->withJson($data); | |
// } | |
// print_r($request->getserverParams()); | |
// print_r($request->getHeader()); | |
$tokon=$request->getserverParams()["HTTP_KANTAPP_COM"]; | |
if($tokon=='kantapp123456') | |
{ | |
echo "Welcome to this site"; | |
} | |
else { | |
$data["status"]="Error"; | |
$data["message"]="Token is invalid"; | |
return $response->withJson($data,401); | |
} | |
}); | |
$app->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment