PHP如何获取angularJS中定义的$http.defaults.headers.common['X-Token']?
PHP how to get the $http.defaults.headers.common['X-Token'] which defined in the angualrJS?
我已经在 AngularJS 中将 $http.defaults.headers.common['X-Token'] 设置为某个值,但是在 chrome 调试工具中,我只能看到 x -token在Access-Control-Request-Headers中,看不到我给x-token设置的具体值。而在PHP这边,如何获取$http.defaults.headers.common['X-Token']?
中的值
Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:zh-CN,zh;q=0.8
Access-Control-Request-Headers:accept, x-token123, x-token
Access-Control-Request-Method:GET
Cache-Control:no-cache
Connection:keep-alive
Host:192.168.1.6
Origin:http://localhost:9000
Pragma:no-cache
Referer:http://localhost:9000/
User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2288.6 Safari/537.36
这就是 header 在开发工具中看不到的价值,类似于我的 plunkerUser-Token
http://plnkr.co/edit/36Dq6UXgyeMEXOzycrua?p=preview
app.config(function ( $httpProvider) {
$httpProvider.defaults.headers.post['User-Token'] = 'finding???';
$httpProvider.defaults.headers.post['Content-Type'] = 'application/json; charset=utf-8';
});
并获得 headers 你可以使用 getallheaders()
which returns array
php
echo json_encode(getallheaders());
我已经在 AngularJS 中将 $http.defaults.headers.common['X-Token'] 设置为某个值,但是在 chrome 调试工具中,我只能看到 x -token在Access-Control-Request-Headers中,看不到我给x-token设置的具体值。而在PHP这边,如何获取$http.defaults.headers.common['X-Token']?
中的值Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:zh-CN,zh;q=0.8
Access-Control-Request-Headers:accept, x-token123, x-token
Access-Control-Request-Method:GET
Cache-Control:no-cache
Connection:keep-alive
Host:192.168.1.6
Origin:http://localhost:9000
Pragma:no-cache
Referer:http://localhost:9000/
User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2288.6 Safari/537.36
这就是 header 在开发工具中看不到的价值,类似于我的 plunkerUser-Token
http://plnkr.co/edit/36Dq6UXgyeMEXOzycrua?p=preview
app.config(function ( $httpProvider) {
$httpProvider.defaults.headers.post['User-Token'] = 'finding???';
$httpProvider.defaults.headers.post['Content-Type'] = 'application/json; charset=utf-8';
});
并获得 headers 你可以使用 getallheaders()
which returns array
php
echo json_encode(getallheaders());