Johannes Kebeck's Blog
03-21-2008, 03:31 PM
<p>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 <a href="http://msdn2.microsoft.com/en-us/library/bb924353.aspx">here</a> 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 <a href="http://www.php.net/">PHP</a> 5.2.5, <a href="http://sourceforge.net/project/showfiles.php?group_id=57663">NuSoap</a> 0.7.3 and <a href="http://httpd.apache.org/">Apache</a> 2.2.8. I’m not using the SOAP-package in PHP directly because there is some issue with digest authentication.
//Generate the Token in PHP
<?php
//Point to the local copy of NuSOAP.
require('nusoap.php');
//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 = 'http://service.mappoint.net/standard-30/mappoint.wsdl';
$client = new nusoap_client($vepWsdl, true);
$err = $client->getError();
if ($err)
{
die('An error occurred while the WSDL was being accessed: '.$err);
}
$client->setCredentials($vepUID,$vepPWD,'digest');
$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
map.SetClientToken(token);
//Load the map
map.LoadMap();
}
</script>
<body onload="GetMap()">
<div id="divMap" style="position:absolute; top:0px; left:0px; width:300px; height:300px;"></div>
</body>
<a href="http://11011.net/software/vspaste"></a>
<p>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:
<p><a href="http://gkxu3a.blu.livefilestore.com/y1psLOdC392akrAnOAftKyL4FxmY6QpztHNjCromkvGFcIbOkG pP5UkZxC6nvu8Hkmt7j3mychQ53Co19ZrxBF_rQ?PARTNER=WR ITER">
http://gkxu3a.blu.livefilestore.com/y1pYZrCEXzy6WELJRy1EpEgoCS2H36NvSemb_KXZRy19LtjzbA bLCSOoT16yK6wLJoeeTCaKlcIF8G_H-8OFvfg04j1wo5dIH5D?PARTNER=WRITER</a>
<p>
<div style="padding-right:0px;display:inline;padding-left:0px;padding-bottom:0px;margin:0px;padding-top:0px">Technorati Tags: <a href="http://technorati.com/tags/Virtual Earth" rel=tag>Virtual Earth</a>,<a href="http://technorati.com/tags/PHP" rel=tag>PHP</a>,<a href="http://technorati.com/tags/Transaction Counting" rel=tag>Transaction Counting</a></div><img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4819404664324524694&page=RSS%3a+Counting+Virtual+Earth+Transactions+wi th+PHP&referrer=" width="1px" height="1px" border="0" alt=""><img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&NA=1149&PI=73329&RF=&DI=3919&PS=85545&TP=johanneskebeck.spaces.live.com>1=JohannesKebeck">
Click here to view the article. (http://JohannesKebeck.spaces.live.com/Blog/cns!42E1F70205EC8A96!3687.entry)
//Generate the Token in PHP
<?php
//Point to the local copy of NuSOAP.
require('nusoap.php');
//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 = 'http://service.mappoint.net/standard-30/mappoint.wsdl';
$client = new nusoap_client($vepWsdl, true);
$err = $client->getError();
if ($err)
{
die('An error occurred while the WSDL was being accessed: '.$err);
}
$client->setCredentials($vepUID,$vepPWD,'digest');
$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
map.SetClientToken(token);
//Load the map
map.LoadMap();
}
</script>
<body onload="GetMap()">
<div id="divMap" style="position:absolute; top:0px; left:0px; width:300px; height:300px;"></div>
</body>
<a href="http://11011.net/software/vspaste"></a>
<p>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:
<p><a href="http://gkxu3a.blu.livefilestore.com/y1psLOdC392akrAnOAftKyL4FxmY6QpztHNjCromkvGFcIbOkG pP5UkZxC6nvu8Hkmt7j3mychQ53Co19ZrxBF_rQ?PARTNER=WR ITER">
http://gkxu3a.blu.livefilestore.com/y1pYZrCEXzy6WELJRy1EpEgoCS2H36NvSemb_KXZRy19LtjzbA bLCSOoT16yK6wLJoeeTCaKlcIF8G_H-8OFvfg04j1wo5dIH5D?PARTNER=WRITER</a>
<p>
<div style="padding-right:0px;display:inline;padding-left:0px;padding-bottom:0px;margin:0px;padding-top:0px">Technorati Tags: <a href="http://technorati.com/tags/Virtual Earth" rel=tag>Virtual Earth</a>,<a href="http://technorati.com/tags/PHP" rel=tag>PHP</a>,<a href="http://technorati.com/tags/Transaction Counting" rel=tag>Transaction Counting</a></div><img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4819404664324524694&page=RSS%3a+Counting+Virtual+Earth+Transactions+wi th+PHP&referrer=" width="1px" height="1px" border="0" alt=""><img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&NA=1149&PI=73329&RF=&DI=3919&PS=85545&TP=johanneskebeck.spaces.live.com>1=JohannesKebeck">
Click here to view the article. (http://JohannesKebeck.spaces.live.com/Blog/cns!42E1F70205EC8A96!3687.entry)