array( array( "coords" => array( array( "point" => array( "x" => 884013.01022, "y" => 6181300.3394 ) ) ), "routingOptions" => array( array( "parameter" => "AVOID_TOLLROADS", "value" => "0" ), array( "parameter" => "OPTIMIZATION", "value" => "90" ) ), "vehicleOptions" => array( array( "parameter" => "EMISSION_CLASS", "value" => "EURO_5" ) ), "linkType" => "NEXT_SEGMENT" ), array( "coords" => array( array( "point" => array( "x" => 873301.60293, "y" => 6099552.7841 ) ) ), "linkType" => "NEXT_SEGMENT" ) ), "options" => array( ), "exceptionPaths" => array( ), "details" => array( "binaryPathDesc" => "false", "boundingRectanglesC" => 5, "boundingRectanglesOffset" => 300, "brunnelManoeuvres" => "false", "detailLevel" => "STANDARD", "dynamicInfo" => "false", "manoeuvreAttributes" => "false", "manoeuvreGroupRatio" => 1, "manoeuvreGroups" => "false", "manoeuvres" => "false", "nodes" => "false", "polygon" => "false", "segmentAttributes" => "false", "segments" => "false", "texts" => "false", "totalRectangle" => "false", "urbanManoeuvres" => "false" ), "countryInfoOptions" => array( "allEuro" => "true", "detailedTollCosts" => "true", "currencyDescription" => "true", "calculatePartTollCosts" => "true", "waypointIndexInTollCostInfo" => "true", "tollTotals" => "true", "namedToll" => "true", "reductionIDs" => array( ) ), "callerContext" => array( "properties" => array( array( "key" => "CoordFormat", "value" => "PTV_MERCATOR" ), array( "key" => "ResponseGeometry", "value" => "WKB" ), array( "key" => "Profile", "value" => "truck-40t" ) ) ) ); $json_data = json_encode($data); //print_r($json_data); curl_setopt($cURL, CURLOPT_URL, $url.$typeRequest); curl_setopt($cURL, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($cURL, CURLOPT_POSTFIELDS, $json_data); curl_setopt($cURL, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true); curl_setopt($cURL, CURLOPT_HTTPHEADER, array( 'Authorization: Basic '.$testbase.'', 'Content-Type: application/json; charset=UTF-8', 'Accept: application/json' )); $result = curl_exec($cURL); curl_close($cURL); print_r($result); $decodedresult = json_decode($result, true); $CALCdistanceKMs = $decodedresult['route']['info']['distance'] / 1000; //$CALCcostsKMS = $decodedresult['partTollCosts']; foreach($decodedresult['partTollCosts'] as $value) { //print $value['distance']; $testcosts = $value['costs']; } $CALCcostsKMS = 0; print $testcosts; if ($testcosts != null){ foreach($testcosts as $value) { $CALCcostsKMS += $value['cost'] / 100; } } //print_r($CALCdistanceKMs); echo("



KM: $CALCdistanceKMs
Costs: $CALCcostsKMS"); ?>