How to use Edith: Distance in PHP?
In the following example all zip codes within the radius of 25 km around the zip code 30175 are shown. The example uses the XML-RPC-libraray by Keith Devens (http://keithdevens.com/software/xmlrpc):
<?php
//include library
require 'xmlrpc.php';
//prepare parameter
$params = array(
XMLRPC_prepare(1), // Your customer id
XMLRPC_prepare('30175'), // zip code
XMLRPC_prepare(25) // radius of 25 km
);
//function call
$result_array = XMLRPC_request('192.168.4.173',
'/gabriel/XML-RPC/plzserver.php',
'edithDistance.showRelated', $params);
$request_ok = $result_array[0];
$result = $result_array[1];
if($request_ok)
{
//show result as table
echo '<table border="1">';
for($i=0;$i<count($result);$i++)
{
echo "<tr>";
echo "<td>{$result[$i]['plz']}</td>";
echo "<td>{$result[$i]['distance']}</td>";
echo "</tr>\n";
}
echo "</table>";
}
else
{
//show error code
echo "Error!<br />Number {$result['faultCode']}, ";
echo "Message: {$result['faultString']}<br />";
}
?>