How to read web header using php?
Basically we read the requesting headers using
print_r($_SERVER['HTTP_MSISDN']);
OR
$headers = apache_request_headers();
print_r($headers['MSISDN']);
But using those code i can't receive the MSISDN number from web header.The MSISDN is send through the web header. so,*is their any other way to read the web header?*The header formate is below.
Example header:
GET /Gamezilla/Wap/Home.aspx HTTP/1.1
User-Agent: MOT-RAZRV3x/85.9B.C0R MIB/BER2.2 Profile/MIDP-2.0 Configuration/CLDC-1.1
Accept: */*, text/css, image/*;q=0.9, application/javascript, application/vbscript, application/xhtml+xml, text/html, application/xml;q=0.9, image/png, image/jpeg, image/jpg, image/gif, image/x-xbitmap
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Cookie: ASP.NET_SessionId=y开发者_StackOverflow社区px2scvweaahpd45gvf0ge45
x-wap-profile: "http://motorola.handango.com/phoneconfig/razrv3x/Profile/razrv3x.rdf"
X-Device-User-Agent: MOT-RAZRV3x/85.9B.C0R MIB/BER2.2 Profile/MIDP-2.0 Configuration/CLDC-1.1
APN: testint
Charging-Characteristics: 0800
Bearer-Type: GPRS
SGSN-IP-Address: 123.123.123.123
Accounting-Session-ID: 213.213.213.213:CA3806A24C452CD2
MSISDN: 00123456789
IP-Address: 213.213.213.213
NAS-IP-Address: 10.123.123.123
Via: 1.1 Bytemobile OSN WebProxy/5.2
Host: wap.abc.com
Cache-Control: max-age=43200
Connection: keep-alive
please help me to receive the MSISDN information from the provided header.
I think you may be looking for http://php.net/manual/en/function.get-headers.php or http://php.net/manual/en/function.http-parse-headers.php.
If PHP is installed as an Apache module, then apache_request_headers()
should work to retrieve all HTTP headers sent with the request. In the case of $_SERVER['HTTP_MSISDN']
not working, perhaps it is not registering as an environment variable. Perhaps you might want to consider installing PHP as an Apache module if you have access to the server.
The standard header for MSISDNs is x-up-calling-line-id. Try to change it to that value. Also you might want to use this PHP-snippet to display all headers:
<?php
$bla = $_SERVER['REMOTE_ADDR'];
echo "<li>REMOTE_ADDR = $bla</li>";
foreach($_SERVER as $h=>$v)
if(ereg('HTTP_(.+)',$h,$hp))
echo "<li>$h = $v</li>\n";
?>
精彩评论