当前位置: 首页>>代码示例>>PHP>>正文


PHP Requests::patch方法代码示例

本文整理汇总了PHP中Requests::patch方法的典型用法代码示例。如果您正苦于以下问题:PHP Requests::patch方法的具体用法?PHP Requests::patch怎么用?PHP Requests::patch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Requests的用法示例。


在下文中一共展示了Requests::patch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getOrderInfo

 public function getOrderInfo($accountId, $orderId)
 {
     $order = \Requests::patch($this->getUrl() . 'accounts/' . $accountId . '/orders/' . $orderId, array('Authorization' => 'Bearer ' . $this->getToken(), 'Content-Type' => 'application/json'));
     //$this->checkAnswer($order);
     print_r($order->headers);
     return $order;
 }
开发者ID:nikopeikrishvili,项目名称:oanda,代码行数:7,代码来源:Orders.php

示例2: request

 public function request($method, $url, $api_key, $data = NULL, $headers = array("Content-Type" => "application/json", "Accept" => "application/json"))
 {
     try {
         $options = array('auth' => new \Requests_Auth_Basic(array($api_key, '')));
         if ($method == "GET") {
             $url_params = is_array($data) ? '?' . http_build_query($data) : '';
             $response = \Requests::get(Client::BASE_URL . $url . $url_params, $headers, $options);
         } else {
             if ($method == "POST") {
                 $response = \Requests::post(Client::BASE_URL . $url, $headers, json_encode($data), $options);
             } else {
                 if ($method == "PATCH") {
                     $response = \Requests::patch(Client::BASE_URL . $url, $headers, json_encode($data), $options);
                 } else {
                     if ($method == "DELETE") {
                         $response = \Requests::delete(Client::BASE_URL . $url, $headers, $options);
                     }
                 }
             }
         }
     } catch (\Exception $e) {
         throw new UnableToConnect();
     }
     if ($response->status_code >= 200 && $response->status_code <= 206) {
         if ($method == "DELETE") {
             return $response->status_code == 204 || $response->status_code == 200;
         }
         return json_decode($response->body);
     }
     if ($response->status_code == 400) {
         $code = 0;
         $message = "";
         try {
             $error = (array) json_decode($response->body)->errors[0];
             $code = key($error);
             $message = current($error);
         } catch (\Exception $e) {
             throw new UnhandledError($response->body, $response->status_code);
         }
         throw new InputValidationError($message, $code);
     }
     if ($response->status_code == 401) {
         throw new AuthenticationError();
     }
     if ($response->status_code == 404) {
         throw new NotFound();
     }
     if ($response->status_code == 403) {
         throw new InvalidApiKey();
     }
     if ($response->status_code == 405) {
         throw new MethodNotAllowed();
     }
     throw new UnhandledError($response->body, $response->status_code);
 }
开发者ID:mango,项目名称:mango-php,代码行数:55,代码来源:client.php

示例3: request

 public function request($method, $url, $api_key, $data = NULL, $headers = array("Content-Type" => "application/json", "Accept" => "application/json"))
 {
     try {
         $options = array('auth' => new AuthBearer($api_key), 'timeout' => 120);
         if ($method == "GET") {
             $url_params = is_array($data) ? '?' . http_build_query($data) : '';
             $response = \Requests::get(Culqi::$api_base . $url . $url_params, $headers, $options);
         } else {
             if ($method == "POST") {
                 $response = \Requests::post(Culqi::$api_base . $url, $headers, json_encode($data), $options);
             } else {
                 if ($method == "PATCH") {
                     $response = \Requests::patch(Culqi::$api_base . $url, $headers, json_encode($data), $options);
                 } else {
                     if ($method == "DELETE") {
                         $response = \Requests::delete(Culqi::$api_base, $options);
                     }
                 }
             }
         }
     } catch (\Exception $e) {
         throw new Errors\UnableToConnect();
     }
     if ($response->status_code >= 200 && $response->status_code <= 206) {
         if ($method == "DELETE") {
             return $response->status_code == 204 || $response->status_code == 200;
         }
         return json_decode($response->body);
     }
     if ($response->status_code == 400) {
         $code = 0;
         $message = "";
         throw new Errors\UnhandledError($response->body, $response->status_code);
     }
     if ($response->status_code == 401) {
         throw new Errors\AuthenticationError();
     }
     if ($response->status_code == 404) {
         throw new Errors\NotFound();
     }
     if ($response->status_code == 403) {
         throw new Errors\InvalidApiKey();
     }
     if ($response->status_code == 405) {
         throw new Errors\MethodNotAllowed();
     }
     throw new Errors\UnhandledError($response->body, $response->status_code);
 }
开发者ID:culqi,项目名称:culqi-php,代码行数:48,代码来源:Client.php

示例4: request

 protected function request($method, $url, $client_id, $secret_id, $data = NULL, $headers = array("Content-Type" => "application/json", "Accept" => "application/json"))
 {
     try {
         $options = array('auth' => new \Requests_Auth_Basic(array($client_id, $secret_id)));
         if ($method == "GET") {
             $url_params = is_array($data) ? '?' . http_build_query($data) : '';
             $response = \Requests::get($this->base_url . $url . $url_params, $headers, $options);
         } else {
             if ($method == "POST") {
                 $response = \Requests::post($this->base_url . $url, $headers, json_encode($data), $options);
             } else {
                 if ($method == "PATCH") {
                     $response = \Requests::patch($this->base_url . $url, $headers, json_encode($data), $options);
                 } else {
                     if ($method == "DELETE") {
                         $response = \Requests::delete($this->base_url . $url, $headers, $options);
                     }
                 }
             }
         }
     } catch (\Exception $e) {
         throw new \Exception(Error_Message::ERROR_CONNECTION);
     }
     if ($response->status_code >= 200 && $response->status_code <= 206) {
         if ($method == "DELETE") {
             return $response->status_code == 204 || $response->status_code == 200;
         }
         return json_decode($response->body);
     }
     if ($response->status_code >= 400 && $response->status_code <= 406) {
         try {
             $error = (array) json_decode($response->body);
             $code = $error['errorCode'];
             $message = $error['errorMessage'];
         } catch (\Exception $e) {
             throw new \Exception($response->body, $response->status_code);
         }
         throw new \Exception($message, $code);
     }
     throw new \Exception($response->body, $response->status_code);
 }
开发者ID:pagomio,项目名称:pagomio-sdk-php,代码行数:41,代码来源:client.php

示例5: testPATCHWithArray

 public function testPATCHWithArray()
 {
     $data = array('test' => 'true', 'test2' => 'test');
     $request = Requests::patch(httpbin('/patch'), array(), $data, $this->getOptions());
     $this->assertEquals(200, $request->status_code);
     $result = json_decode($request->body, true);
     $this->assertEquals(array('test' => 'true', 'test2' => 'test'), $result['form']);
 }
开发者ID:majinhui04,项目名称:pretty,代码行数:8,代码来源:Base.php


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