The Wireless Universal Resource File

4.7 How do I read data from the WAP device (telephone number etc)?

There is some information available through HTTP, but it is limited. Things like the telephone number of a WAP cell phone will most likely be unavailable due to the fact that only a few WAP gateways pass this information on. Also there are regulations regarding privacy in some countries that make this illegal.

Basically what you are left with is whatever the WAP gateway is set up to pass along to the HTTP server. This varies from WAP gateway to WAP gateway. Openwave's UP.link gateway is the best in this case, because it returns a string in the HTTP header called UP_X_SUBNO which contains the subscriber number. The Ericsson gateway pass along a string that is unique to each device, but it does not contain the subscriber number in clear text.

The information is passed from the WAP gateway to the HTTP server each time the WAP device requests a URL from the HTTP server.

The following PHP script will display all the HTTP header information passed on by the gateway. With a WML browser, you can try the application here. Like all example applications in this FAQ, this one is available at the URL DEMO

The first part gets all the standard HTTP header info. For more detail on those, check the W3C HTTP specifications. The second part pulls out some other header stuff that is mostly there for the sake of the example.

<?
  header("Content-type: text/vnd.wap.wml");
  echo("<?xml version=\"1.0\"?>\n");
  echo("<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://...\">\n\n");
  echo("<!-- Code written in Microsoft NOTEPAD.EXE -->\n");
?>
<wml>
  <card id="init" title="Client Info">
    <p>
      <?
        // First part - standard HTTP stuff
        $headers = getallheaders();
        while (list($header, $value) = each($headers)) {
          echo strtoupper($header).": ". $value."<br/>\n";
        }
        // Second part
        echo("REMOTE_ADDR: ".$REMOTE_ADDR."<br/>\n");               // IP address of the client side
        echo("REMOTE_PORT: ".$REMOTE_PORT."<br/>\n");               // Port at the client side
        echo("REMOTE_USER: ".$REMOTE_USER."<br/>\n");               // Name of authenticated user
        echo("GATEWAY_INTERFACE: ".$GATEWAY_INTERFACE."<br/>\n");   // Gateway Interface type
        echo("SERVER_PROTOCOL: ".$SERVER_PROTOCOL."<br/>\n");       // Protocol used by the server
        echo("REQUEST_METHOD: ".$REQUEST_METHOD."<br/>\n");         // Request Method
        echo("HTTP_CONNECTION: ".$HTTP_CONNECTION."<br/>\n");       // Connection type
        echo("HTTP_VIA: ".$HTTP_VIA."<br/>\n");                     // Host it connected via (proxy)
      ?>
    </p>
  </card>
</wml>

Also, Henrik Gemal has an online WML based tool for displaying even more information from the HTTP headers, the server environment and your browser. The tool, called BrowserSpy, is available for WML browsers at

has submitted a Perl script that displays the subscriber number (if found). The script is available from the WAP Demo section at DEMO.

Note that the only WAP Gateway that uses the UP_X_SUBNO header is UP.Link. If you are testing the script via another brand of gateway, the subscriber number will not appear. However, this gateway is widely used in the US. For this reason, the subscriber number cannot be used as a unique identifier, at least not on a global basis. Not everyone in the world are using UP.Link gateways.

Both the WML and the Perl script are downloadable.

[ Main ]   [ 04 - Serving WML contents ]