當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。