Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Example of how to perform a price calculation:

Code Block
languagephp
<?php
$json = array("portal" => "DKWWFCOPEN",
              "username" => "MYUSERNAME",
              "password" => "MYPASSWORD",
              "apikey" => "", // empty for now
              "commands" => array(array("command" => "GetPriceCalculation",
                                        "from_country" => 23,
                                        "from_location" => 1,
                                        "to_country" => 23,
                                        "to_location" => 2,
                                        "pcs1" => 1,
                                        "packtype1" => 23,
                                        "weight1" => 100,
                                        "volume1"  => 0.5*0.5*0.1,

...


                                        "width1" => 50,

...

 "height1" => 50, "length1" => 10,
                                        "pcs2" => 1,
                                        "packtype2" => 23,
                                        "weight2" => 100,
                                        "

...

volume2" => 

...

0.5*0.5*0.1,
                                        "

...

width2" => 50, "height2" => 50, "length2" => 10,
                                       )
                                 )
           );

$d = file_get_contents("https://portal.ff.geodis.com/api/endpoint.php?json=".json_encode($json));
$d = json_decode($d, true);

if ($d['status'] != 1)   exit('failed: '.$d['msg']);
$c = $d['results'][0];
if ($c['status'] != 1)   exit('GetPriceCalculation failed: '.$c['msg']);
$sheets = $c['sheets'];  // the result for each price sheet
foreach ($sheets as $sheet) {
    // the result for a price sheet includes title,currency,total cost,addon,transittime,note and lines
    // each line describes a fee or other cost
    
    echo "\n";
    echo "Title: ".$sheet['title']."\n";
    echo "Currency: ".$sheet['currency']."\n";
    echo "Total cost: ".$sheet['total_excl']."\n";
}
?>