Im using Slim Framework as an API. Im making a GET request to it. But I cannot get the headers. My PHP file looks like:
require 'Slim/Slim.php';
$app = new Slim();
$app->get('/project/:id', add_authorize(), 'getProject');
$app->run();
function getProject($project_title) {
//connect to database and return project details
}
function add_authorize() {
return function (){
$app = Slim::getInstance();
$charset = $app->request->headers->get('ACCEPT_CHARSET');
};
}
I get the response:
( ! ) Fatal error: Cannot access protected property Slim::$request in C:\wamp\www\server\device_api\index.php on line 23
Call Stack
# Time Memory Function Location
1 0.0010 248528 {main}( ) ..\index.php:0
2 0.0240 860056 Slim->run( ) ..\index.php:9
3 0.0240 878816 Slim_Route->dispatch( ) ..\Slim.php:1052
4 0.0240 878864 call_user_func:{C:\wamp\www\server\device_api\Slim\Route.php:387} ( ) ..\Route.php:387
5 0.0240 878944 {closure:C:\wamp\www\server\device_api\index.php:19-25}( ) ..\Route.php:387
I have tried absolutely everything but to no avail. I also tried getting headers directly with:
$device_id = $_SERVER['HTTP_DEVICE_ID'];
but this also failed. Any ideas how I can get a header?