當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ApiException類代碼示例

本文整理匯總了PHP中ApiException的典型用法代碼示例。如果您正苦於以下問題:PHP ApiException類的具體用法?PHP ApiException怎麽用?PHP ApiException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ApiException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __doCurl

 private static function __doCurl($url, $data, $additionalHeaders)
 {
     $curlHandle = curl_init($url);
     if ($curlHandle === FALSE) {
         $exception = new ApiException("Failed to connect to url {$url}", Config::$LOG_LEVEL_ERROR_KEY);
         $exception->setAdditionalInfo("source", "ApiCurl::__doCurl");
         $exception->setAdditionalInfo("url", $url);
         throw $exception;
     }
     if (!empty($data)) {
         curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $data);
         curl_setopt($curlHandle, CURLOPT_POST, 1);
     }
     curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt($curlHandle, CURLOPT_MAXREDIRS, Config::$CURL_MAX_REDIRECTS);
     curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, Config::$CURL_CONNECTION_TIMEOUT);
     if (!empty($additionalHeaders)) {
         foreach ($additionalHeaders as $key => $value) {
             curl_setopt($curlHandle, $key, $value);
         }
     }
     $result = curl_exec($curlHandle);
     curl_close($curlHandle);
     if ($result === FALSE) {
         $exception = new ApiException("Failed to exec curl to {$url}", Config::$LOG_LEVEL_ERROR_KEY);
         $exception->setAdditionalInfo("source", "ApiCurl::__doCurl");
         $exception->setAdditionalInfo("url", $url);
         $exception->setAdditionalInfo("data", $data);
         $exception->setAdditionalInfo("additionalHeaders", $additionalHeaders);
         throw $exception;
     }
     return $result;
 }
開發者ID:reysub,項目名稱:MVC-Template,代碼行數:34,代碼來源:ApiCurl.php

示例2: delete

 public static function delete($key)
 {
     unset($_COOKIE[$key]);
     if (!setcookie($key, NULL, time() - 1, "/")) {
         $exception = new ApiException("Failed to set cookie {$key}", Config::$LOG_LEVEL_WARNING_KEY);
         $exception->setAdditionalInfo("source", "ApiCookies::delete");
         $exception->setAdditionalInfo("key", $key);
         throw $exception;
     }
 }
開發者ID:reysub,項目名稱:MVC-Template,代碼行數:10,代碼來源:ApiCookies.php

示例3: post

 /**
  * Resource methods
  */
 public function post()
 {
     // Just a dummy redirect to prevent errors in checkout/reward/reward.
     $this->request->post['redirect'] = 'checkout/cart';
     $data = parent::getInternalRouteData('checkout/reward/reward', true);
     ApiException::evaluateErrors($data);
 }
開發者ID:projectwife,項目名稱:tesitoo-opencart,代碼行數:10,代碼來源:reward_points_base.php

示例4: post

 /**
  * Resource methods
  */
 public function post()
 {
     $data = parent::getInternalRouteData('tool/upload', true);
     ApiException::evaluateErrors($data);
     $file = array("file" => $this->getFile($data));
     $this->response->setOutput($file);
 }
開發者ID:projectwife,項目名稱:tesitoo-opencart,代碼行數:10,代碼來源:upload_base.php

示例5: get

 /**
  * Resource methods
  */
 public function get()
 {
     $data = parent::getInternalRouteData('checkout/cart');
     ApiException::evaluateErrors($data, false);
     $cart = array('cart' => $this->getCart($data));
     $this->response->setOutput($cart);
 }
開發者ID:projectwife,項目名稱:tesitoo-opencart,代碼行數:10,代碼來源:cart_base.php

示例6: put

 /**
  * Resource methods
  */
 public function put($id = NULL)
 {
     $this->request->convertBoolToYesNoRadioValue('newsletter');
     $this->request->server['REQUEST_METHOD'] = 'POST';
     $data = parent::getInternalRouteData('account/newsletter');
     ApiException::evaluateErrors($data);
 }
開發者ID:projectwife,項目名稱:tesitoo-opencart,代碼行數:10,代碼來源:newsletter_base.php

示例7: post

 /**
  * Resource methods
  */
 public function post()
 {
     $this->request->setDefaultParameters($this->defaultParameters);
     $this->request->convertBoolToCheckbox('agree');
     $this->request->convertBoolToYesNoRadioValue('newsletter');
     $data = parent::getInternalRouteData('account/register');
     ApiException::evaluateErrors($data);
 }
開發者ID:projectwife,項目名稱:tesitoo-opencart,代碼行數:11,代碼來源:register_base.php

示例8: post

 /**
  * Resource methods
  */
 public function post()
 {
     $this->user->logout();
     unset($this->session->data['token']);
     $data = array('success' => true);
     $this->response->setOutput($data);
     ApiException::evaluateErrors($data);
 }
開發者ID:projectwife,項目名稱:tesitoo-opencart,代碼行數:11,代碼來源:logout_base.php

示例9: delete

 public function delete($id = NULL)
 {
     if ($id !== NULL) {
         $this->request->get['remove'] = $id;
     }
     $data = parent::getInternalRouteData('account/wishlist');
     ApiException::evaluateErrors($data);
 }
開發者ID:projectwife,項目名稱:tesitoo-opencart,代碼行數:8,代碼來源:wishlist_base.php

示例10: post

 public function post()
 {
     $this->request->setDefaultParameters($this->defaultParameters);
     $data = parent::getInternalRouteData('checkout/shipping_method/save', true);
     if (isset($data['redirect'])) {
         $this->redirect($data['redirect']);
     }
     ApiException::evaluateErrors($data);
 }
開發者ID:projectwife,項目名稱:tesitoo-opencart,代碼行數:9,代碼來源:shipping_method_base.php

示例11: put

 public function put()
 {
     $this->request->setDefaultParameters($this->defaultParameters);
     $this->request->server['REQUEST_METHOD'] = 'POST';
     $data = parent::getInternalRouteData('account/edit');
     ApiException::evaluateErrors($data);
     $account = array('account' => $this->getAccount($data));
     $this->response->setOutput($account);
 }
開發者ID:projectwife,項目名稱:tesitoo-opencart,代碼行數:9,代碼來源:account_base.php

示例12: get

 /**
  * Resource methods
  */
 public function get()
 {
     $data = parent::getInternalRouteData('checkout/confirm');
     if (isset($data['redirect'])) {
         $this->redirect($data['redirect']);
     }
     ApiException::evaluateErrors($data);
     $order = array('order' => $this->getOrder($data));
     $this->response->setOutput($order);
 }
開發者ID:projectwife,項目名稱:tesitoo-opencart,代碼行數:13,代碼來源:confirm_base.php

示例13: post

 /**
  * Resource methods
  */
 public function post()
 {
     $this->request->setDefaultParameters($this->defaultParameters);
     $this->request->convertBoolToCheckbox('shipping_address');
     $data = parent::getInternalRouteData('checkout/guest/save', true);
     if (isset($data['redirect'])) {
         $this->redirect($data['redirect']);
     }
     ApiException::evaluateErrors($data);
 }
開發者ID:projectwife,項目名稱:tesitoo-opencart,代碼行數:13,代碼來源:guest_base.php

示例14: delete

 public function delete($id)
 {
     $cartItemKeys = explode(',', $id);
     foreach ($cartItemKeys as $cartItemKey) {
         $this->request->post['key'] = $cartItemKey;
         $data = parent::getInternalRouteData('checkout/cart/remove', true);
         ApiException::evaluateErrors($data);
     }
     // Return cart
     $this->request->post = array();
     $this->get();
 }
開發者ID:projectwife,項目名稱:tesitoo-opencart,代碼行數:12,代碼來源:product_base.php

示例15: __sendMail

 private static function __sendMail($sender, $receivers, $subject, $body, $replyTo, $ccs, $bccs, $contentType)
 {
     $replyTo = self::__parseField(empty($replyTo) ? $sender : $replyTo);
     $sender = self::__parseField($sender);
     $receivers = self::__parseField($receivers);
     $ccs = self::__parseField($ccs);
     $bccs = self::__parseField($bccs);
     $headers = self::__composeHeaders($sender["forHeaders"], $receivers["forHeaders"], $subject, $replyTo["forHeaders"], $ccs["forHeaders"], $bccs["forHeaders"], $contentType);
     if (!mail($receivers["forEmail"], $subject, $body, $headers)) {
         $exception = new ApiException("Failed to send email", Config::$LOG_LEVEL_WARNING_KEY);
         $exception->setAdditionalInfo("source", "ApiMail::__sendMail");
         $exception->setAdditionalInfo("sender", $sender);
         $exception->setAdditionalInfo("receivers", $receivers);
         $exception->setAdditionalInfo("subject", $subject);
         $exception->setAdditionalInfo("body", $body);
         $exception->setAdditionalInfo("replyTo", $replyTo);
         $exception->setAdditionalInfo("ccs", $ccs);
         $exception->setAdditionalInfo("bccs", $bccs);
         $exception->setAdditionalInfo("contentType", $contentType);
         throw $exception;
     }
 }
開發者ID:reysub,項目名稱:MVC-Template,代碼行數:22,代碼來源:ApiMail.php


注:本文中的ApiException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。