Counting Virtual Earth Transactions with PHP

Those who have a Virtual Earth contract in place and want to count transactions can do so by creating a token through a SOAP web service request and attaching it to all subsequent request to the Virtual Earth platform. The process is well explained here for web service request in .NET and Java. If you are using PHP you can follow the sample below. I created this sample for an environment using PHP 5.2.5, NuSoap 0.7.3 and Apache 2.2.8. I’m not using the SOAP-package in PHP directly because there is some issue with digest authentication.

    <title>PHP Test</title>
    <script src="" type="text/javascript"></script>
    <script type="text/javascript">
      //Generate the Token in PHP 
      //Point to the local copy of NuSOAP.
      //Virtual Earth Platform ID goes here.
      $vepUID = 'YOUR USER ID';
      //Virtual Earth Platform password goes here.
      $vepPWD = 'YOUR PWD';
      //Customer Identification works only with production accounts
      $vepWsdl = '';
      $client = new nusoap_client($vepWsdl, true);
      $err = $client->getError();
      if ($err)
        die('An error occurred while the WSDL was being accessed: '.$err);
      $client_ip = $_SERVER['REMOTE_ADDR'];
      //Display the Client IP-Address
      $tokenSpecification = array(
         'ClientIPAddress' => $client_ip, 
         'TokenValidityDurationMinutes' => 480);
      $getClientToken = array('specification' => $tokenSpecification);   
      $res=$client->call('GetClientToken', array('parameters' => $getClientToken));
      //Make sure no fault or error has occurred.
      if ($client->fault)
      die('Fault occurred using Web Service: '.print_r($res,true));
      if ($client->getError())
         die('An error occurred while using Web Service: '.$client->getError());
      echo('var token = ''.$res[GetClientTokenResult].'';');
      var map = null;
      function GetMap()
        map = new VEMap('divMap');
        //Enable Transaction Counting
        //Load the map
  <body onload="GetMap()">
    <div id="divMap" style="position:absolute; top:0px; left:0px; width:300px; height:300px;"></div>

Once you have the transaction counting in place you can retrieve nice reports which show the transaction by type and allow you comparisons with the previous month:


This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s