- PHP 5.3+
- iconv or mbsrting extensions for the SPSR
- Zend Framework
$ems = new \shipping\Ems();
$from = 'city--moskva';
$target = 'city--astrahan';
$weight = floatval(1200 / 1000);
$country = 'US';
// default
var_dump($ems->calculate($from, $target, $weight));
// international
var_dump($ems->calculate($from, $country, $weight, \shipping\Ems::TYPE_ATT));
$ems = new \shipping\Ems();
var_dump($ems->getRegions());
var_dump($ems->getCities());
var_dump($ems->getCountries());
// you can also get unformatted data using: "cities", "regions", "countries" or "russia"
var_dump($ems->getRawLocations('cities'));
$ems = new \shipping\Ems();
var_dump($ems->getMaxWeight());
$sid = $spsr->getSid(123321, 132234);
$spsr = new \shipping\Spsr();
$options = array(
'Country' => '209|0',
'ToRegion' => '7|0',
'ToCity' => '124|0',
'FromCountry' => '209|0',
'FromRegion' => '40|0',
'FromCity' => '992|0',
'Weight' => 1, // KG
'SID' => $spsr->getSid('login', 'password') // optional
);
var_dump($spsr->calculate($options));
$spsr = new \shipping\Spsr();
// list of entries with first and second value for the calculation
var_dump($spsr->getRegions());
var_dump($spsr->getCountries());
$spsr = new \shipping\Spsr();
// one entry
$spsr->findCity('Москва');
// more than one entry
$spsr->findCity('Челя');
All functions return false in case the post service provides incorrect answer.
Exception - client request failed UnexpectedValueException - service provides unexpected data