コード例 #1
0
ファイル: Request.php プロジェクト: bkuhl/simple-ups
 public function __construct($debug = null)
 {
     if ($debug == null) {
         $this->debug = UPS::getDebug();
     }
     $loadedExtensions = get_loaded_extensions();
     if (!in_array('curl', $loadedExtensions)) {
         throw new \Exception('CURL extension must be installed in order to use ' . UPS::$libraryName);
     }
     if (!in_array('dom', $loadedExtensions)) {
         throw new \Exception('DOM extension must be installed in order to use ' . UPS::$libraryName);
     }
     if (!in_array('SimpleXML', $loadedExtensions)) {
         throw new \Exception('SimpleXML extension must be installed in order to use ' . UPS::$libraryName);
     }
     if (!in_array('date', $loadedExtensions)) {
         throw new \Exception('Date extension must be installed in order to use ' . UPS::$libraryName);
     }
     if (version_compare(PHP_VERSION, '5.3.0') < 1) {
         throw new \Exception(UPS::$libraryName . ' requires at least PHP version 5.3');
     }
     unset($loadedExtensions);
     $this->setAccessLicenseNumber(UPS::getAccessLicenseNumber());
     $this->setUserId(UPS::getUserId());
     $this->setPassword(UPS::getPassword());
     libxml_use_internal_errors(true);
 }
コード例 #2
0
ファイル: shipper.php プロジェクト: camigreen/ttop
 public function getRates()
 {
     //try {
     //define a package, we could specify the dimensions of the box if we wanted a more accurate estimate
     //$this->setShipper();
     //$shipper = $this->getShipper();
     $shipment = new \SimpleUPS\Rates\Shipment();
     $shipment->setDestination($this->destination);
     foreach ($this->packages as $package) {
         $shipment->addPackage($package);
     }
     //$service = new \SimpleUPS\Service();
     //$service->setCode('03');
     //$shipment->setService($service);
     //$shipment->setShipper($shipper);
     $rates = UPS::getRates($shipment);
     foreach ($rates as $shippingMethod) {
         $this->_rates[$shippingMethod->getService()->getCode()] = $shippingMethod;
     }
     return $this->_rates;
     //} catch (ShipperException $e) {
     //doh, something went wrong
     echo 'Failed: (' . get_class($e) . ') ' . $e->getMessage() . '<br/>';
     echo 'Stack trace:<br/><pre>' . $e->getTraceAsString() . '</pre>';
     //}
     if (UPS::getDebug()) {
         UPS::getDebugOutput();
     }
 }