• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ApiException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中ApiException的典型用法代码示例。如果您正苦于以下问题:PHP ApiException类的具体用法?PHP ApiException怎么用?PHP ApiException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ApiException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: post

 /**
  * Resource methods
  */
 public function post()
 {
     // Validate if customer is logged in. This is needed because in the parent::validate the checkout/checkout route serves two purposes.
     if (!$this->customer->isLogged()) {
         throw new ApiException(ApiResponse::HTTP_RESPONSE_CODE_BAD_REQUEST, ErrorCodes::ERRORCODE_USER_NOT_LOGGED_IN, ErrorCodes::getMessage(ErrorCodes::ERRORCODE_USER_NOT_LOGGED_IN));
     }
     $this->request->setDefaultParameters($this->defaultParameters);
     $data = parent::getInternalRouteData('checkout/shipping_address/save', true);
     if (isset($data['redirect'])) {
         $this->redirect($data['redirect']);
     }
     ApiException::evaluateErrors($data);
 }
开发者ID:projectwife,项目名称:tesitoo-opencart,代码行数:16,代码来源:shipping_address_base.php


示例17: post

 /**
  * Resource methods
  */
 public function post()
 {
     $user = $this->user;
     $data = array();
     if (isset($this->request->post['username']) && isset($this->request->post['username']) && $user->login($this->request->post['username'], $this->request->post['password'])) {
         $data['user'] = array('username' => $user->getUserName(), 'user_id' => $user->getId(), 'user_group_id' => $user->getGroupId(), 'vendor_id' => $user->getVP());
     } else {
         // Need to keep the static messages in a separate file (Keep it in API end ?)
         $data['errors'] = array('code' => "error_warning", 'message' => "Warning: No match for Username and/or Password.");
     }
     $this->response->setOutput($data);
     ApiException::evaluateErrors($data);
 }
开发者ID:projectwife,项目名称:tesitoo-opencart,代码行数:16,代码来源:login_base.php


示例18: findErrors

 private static function findErrors($error, $keyPrefix, $apiExceptionObject, $warningIsError = true)
 {
     if (is_array($error)) {
         foreach ($error as $errorKey => $errorValue) {
             if (!($warningIsError === false && $errorKey == 'warning')) {
                 $key = $keyPrefix . '_' . $errorKey;
                 ApiException::findErrors($errorValue, $key, $apiExceptionObject, $warningIsError);
             }
         }
     } else {
         $apiExceptionObject->addError($keyPrefix, $error);
     }
 }
开发者ID:projectwife,项目名称:tesitoo-opencart,代码行数:13,代码来源:apiexception.php


示例19: getRecurringDescription

 public function getRecurringDescription($id = NULL)
 {
     $this->request->post['product_id'] = $id;
     $this->request->post['recurring_id'] = $this->request->get['recurring_id'];
     if (isset($this->request->get['quantity'])) {
         $this->request->post['quantity'] = $this->request->get['quantity'];
     }
     $data = parent::getInternalRouteData('product/product/getRecurringDescription', true);
     ApiException::evaluateErrors($data);
     if (isset($data['success'])) {
         $product = array('recurring_description' => $data['success']);
         $this->response->setOutput($product);
     } else {
         // No description found.
         throw new ApiException(ApiResponse::HTTP_RESPONSE_CODE_NOT_FOUND, ErrorCodes::ERRORCODE_RECURRING_DESCRIPTION_NOT_FOUND, ErrorCodes::getMessage(ErrorCodes::ERRORCODE_RECURRING_DESCRIPTION_NOT_FOUND));
     }
 }
开发者ID:projectwife,项目名称:tesitoo-opencart,代码行数:17,代码来源:product_base.php


示例20: post

 /**
  * Resource methods
  */
 public function post()
 {
     $user = $this->user;
     $data = array();
     if ($this->user->isLogged()) {
         if (!$this->user->hasPermission('modify', 'user/vdi_user_password')) {
             throw new ApiException(ApiResponse::HTTP_RESPONSE_CODE_BAD_REQUEST, ErrorCodes::ERRORCODE_VENDOR_NOT_ALLOWED, "not allowed");
         }
         //log in to check old password
         if (!$user->login($this->user->getUserName(), $this->request->post['old_password'])) {
             throw new ApiException(ApiResponse::HTTP_RESPONSE_CODE_UNAUTHORIZED, ErrorCodes::ERRORCODE_USER_NOT_LOGGED_IN, "error confirming old password");
         }
         //now set new password
         if ($this->user->getId()) {
             $this->load->model('user/vdi_user_password');
             $this->model_user_vdi_user_password->editPassword($this->user->getId(), $this->request->post['new_password']);
             $data = array('success' => true);
         }
     } else {
         throw new ApiException(ApiResponse::HTTP_RESPONSE_CODE_UNAUTHORIZED, ErrorCodes::ERRORCODE_USER_NOT_LOGGED_IN, "user not logged in");
     }
     $this->response->setOutput($data);
     ApiException::evaluateErrors($data);
 }
开发者ID:projectwife,项目名称:tesitoo-opencart,代码行数:27,代码来源:password.php



注:本文中的ApiException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ApiFormatBase类代码示例发布时间:2022-05-23
下一篇:
PHP ApiError类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap