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


PHP Request::patch方法代码示例

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


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

示例1: RestClient

 /**
  * Interface for performing requests to PromisePay endpoints
  *
  * @param string $method required One of the four supported requests methods (get, post, delete, patch)
  * @param string $entity required Endpoint name
  * @param string $payload optional URL encoded data query
  * @param string $mime optional Set specific MIME type. Supported list can be seen here: http://phphttpclient.com/docs/class-Httpful.Mime.html
  */
 public static function RestClient($method, $entity, $payload = null, $mime = null)
 {
     // Check whether critical constants are defined.
     if (!defined(__NAMESPACE__ . '\\API_URL')) {
         die("Fatal error: API_URL constant missing. Check if environment has been set.");
     }
     if (!defined(__NAMESPACE__ . '\\API_LOGIN')) {
         die("Fatal error: API_LOGIN constant missing.");
     }
     if (!defined(__NAMESPACE__ . '\\API_PASSWORD')) {
         die("Fatal error: API_PASSWORD constant missing.");
     }
     if (!is_null($payload)) {
         if (is_array($payload) || is_object($payload)) {
             $payload = http_build_query($payload);
         }
         // if the payload isn't array or object, leave it intact
     }
     $url = constant(__NAMESPACE__ . '\\API_URL') . $entity . '?' . $payload;
     switch ($method) {
         case 'get':
             $response = Request::get($url)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         case 'post':
             $response = Request::post($url)->body($payload, $mime)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         case 'delete':
             $response = Request::delete($url)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         case 'patch':
             $response = Request::patch($url)->body($payload, $mime)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         default:
             throw new Exception\ApiUnsupportedRequestMethod("Unsupported request method {$method}.");
     }
     // check for errors
     if ($response->hasErrors()) {
         $errors = static::buildErrorMessage($response);
         switch ($response->code) {
             case 401:
                 throw new Exception\Unauthorized($errors);
                 break;
             case 404:
                 throw new Exception\NotFound($errors);
             default:
                 throw new Exception\Api($errors);
                 break;
         }
     }
     return $response;
 }
开发者ID:kublermdk,项目名称:promisepay-php,代码行数:59,代码来源:PromisePay.php

示例2: patchRequest

 public function patchRequest($url, $data = null)
 {
     $access_token = $this->config['code'];
     $request_url = $this->config['endpoint'] . $url;
     error_log('patchRequest ' . $request_url . ' data ' . $data);
     $response = \Httpful\Request::patch($request_url)->addHeader('Authorization', "Bearer {$access_token}")->sendsJson()->body($data)->send();
     error_log('patchRequest response ' . $response);
     $response = json_decode($response);
     if (isset($response->error)) {
         throw new Exception('eenvoudcrm error : ' . json_encode($response));
     }
     return $response;
 }
开发者ID:strikles,项目名称:php,代码行数:13,代码来源:integrationMoneyBirdController2.php

示例3: _PATCH

 public static function _PATCH($url, $body = '{}')
 {
     $real_url = \Marketcloud\Marketcloud::$apiBaseUrl . $url;
     $response = \Httpful\Request::patch($real_url)->sendsJson()->body($body)->addHeader('Authorization', \Marketcloud\Marketcloud::getAuthorizationHeader())->send();
     // We check the response code
     // If the code is 401, then the Token might be expired.
     // If it is the case, we re-authenticate the client using the stored credentials.
     //
     if ($response->code == 401) {
         // We have to re-authenticate
         $auth_response = \Marketcloud\Marketcloud::authenticate();
         return self::_PATCH($url, $body);
     } else {
         return $response;
     }
 }
开发者ID:marketcloud,项目名称:marketcloud-php,代码行数:16,代码来源:ApiResource.php

示例4: processAction

 public function processAction(CRM_Civirules_TriggerData_TriggerData $triggerData)
 {
     //do the http post process
     $uri = $this->getFullUri($triggerData);
     $method = $this->getHttpMethod();
     $body = http_build_query($this->getBodyParams($triggerData));
     switch (strtolower($method)) {
         case 'post':
             $request = \Httpful\Request::post($uri, $body);
             break;
         case 'put':
             $request = \Httpful\Request::put($uri, $body);
             break;
         case 'delete':
             $request = \Httpful\Request::delete($uri);
             break;
         case 'head':
             $request = \Httpful\Request::head($uri);
             break;
         case 'patch':
             $request = \Httpful\Request::patch($uri, $body);
             break;
         case 'options':
             $request = \Httpful\Request::options($uri, $body);
             break;
         case 'get':
             $request = $response = \Httpful\Request::get($uri);
             break;
         default:
             throw new Exception('Invalid HTTP Method');
     }
     $request->neverSerializePayload();
     $request = $this->alterHttpRequestObject($request, $triggerData);
     $response = $request->send();
     $this->handleResponse($response, $request, $triggerData);
 }
开发者ID:CiviCooP,项目名称:org.civicoop.civiruleshttppost,代码行数:36,代码来源:HttpPostAction.php

示例5: RestClient

 public function RestClient($method, $entity, $payload = null, $mime = null)
 {
     $username = $this->Login();
     $password = $this->Password();
     $url = $this->BaseUrl() . $entity . "?" . $payload;
     switch ($method) {
         case 'get':
             $response = Request::get($url)->authenticateWith($username, $password)->send();
             return $response;
             break;
         case 'post':
             $response = Request::post($url)->body($payload, $mime)->authenticateWith($username, $password)->send();
             return $response;
             break;
         case 'delete':
             $response = Request::delete($url)->authenticateWith($username, $password)->send();
             return $response;
             break;
         case 'patch':
             $response = Request::patch($url)->body($payload, $mime)->authenticateWith($username, $password)->send();
             return $response;
             break;
     }
 }
开发者ID:gjorgic,项目名称:my-promisepay-php,代码行数:24,代码来源:ApiAbstract.php

示例6: RestClient

 /**
  * Method for performing requests to PromisePay endpoints.
  *
  * @param string $method One of the four supported requests methods (get, post, delete, patch)
  * @param string $entity Endpoint name
  * @param string $payload optional URL encoded data query
  * @param string $mime optional Set specific MIME type.
  */
 public static function RestClient($method, $entity, $payload = null, $mime = null)
 {
     Helpers\Functions::runtimeChecks();
     if (!is_scalar($payload) && $payload !== null) {
         $payload = http_build_query($payload);
     }
     $url = constant(__NAMESPACE__ . '\\API_URL') . $entity . '?' . $payload;
     if (self::$sendAsync) {
         self::$pendingRequests[] = array($method, $url);
         // set and return an empty array instead of null
         // to avoid breaking any BC
         self::$jsonResponse = array();
         return self::$jsonResponse;
     }
     switch ($method) {
         case 'get':
             $response = \Httpful\Request::get($url)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         case 'post':
             $response = \Httpful\Request::post($url)->body($payload, $mime)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         case 'delete':
             $response = \Httpful\Request::delete($url)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         case 'patch':
             $response = \Httpful\Request::patch($url)->body($payload, $mime)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         default:
             throw new Exception\ApiUnsupportedRequestMethod(sprintf('%s is not a supported request method.', $method));
     }
     self::$debugData = $response;
     if (self::isRetry() && ($response->http_code === 503 || $response->http_code === 504)) {
         if (self::$debug) {
             fwrite(STDOUT, sprintf("HTTP Code %d detected while retrying is enabled; retrying" . PHP_EOL, $response->http_code));
         }
         return forward_static_call_array(array(__NAMESPACE__ . '\\PromisePay', 'RestClient'), func_get_args());
     }
     // check for errors
     if ($response->hasErrors()) {
         $errors = Helpers\Functions::buildErrorMessage($response);
         switch ($response->code) {
             case 401:
                 throw new Exception\Unauthorized($errors);
                 break;
             case 404:
                 if (empty($errors)) {
                     $errors = "{$url} wasn't found.";
                 }
                 throw new Exception\NotFound($errors);
                 break;
             default:
                 if (empty($errors) && isset($response->raw_headers)) {
                     list($errors) = explode("\n", $response->raw_headers);
                 }
                 throw new Exception\Api($errors);
         }
     }
     $data = json_decode($response, true);
     if ($data) {
         self::$jsonResponse = $data;
     }
     return $response;
 }
开发者ID:ninoskopac,项目名称:promisepay-php,代码行数:71,代码来源:PromisePay.php

示例7: patch

 /**
  * Запрос PATCH
  * @param $uri
  * @return mixed
  */
 public function patch($uri)
 {
     $this->request = Request::patch($uri);
     return $this;
 }
开发者ID:rutube,项目名称:php-api-client,代码行数:10,代码来源:ClientHttpful.php

示例8: makeCall

 /**
  *
  * Makes a call to the API server and returns the response
  *
  * @param string $modulePath The module path (generally provided by the API Class)
  * @param string $id The id for a get method
  * @param array  $params Any params that need to be added used for creating, editing, or filtering data
  * @param int    $method The HTTP method to be used
  * @return mixed The result of the call
  */
 public function makeCall($modulePath, $id = '', $params = [], $method = self::METHOD_GET)
 {
     $uri = $this->endPoint . '/' . $modulePath . (!empty(trim($id)) ? '/' . $id : '');
     //Setup Request Object
     switch ($method) {
         case self::METHOD_GET:
             $request = Request::get($uri)->sendsJson();
             break;
         case self::METHOD_POST:
             $request = Request::post($uri)->sendsJson();
             break;
         case self::METHOD_PATCH:
             $request = Request::patch($uri)->sendsJson();
             break;
         case self::METHOD_DELETE:
             $request = Request::delete($uri)->sendsJson();
             break;
         default:
             $request = Request::get($uri)->sendsJson();
             break;
     }
     $request->expectsJson();
     //Handle Data
     if ($method == self::METHOD_GET || $method == self::METHOD_DELETE) {
         $params['access_token'] = $this->token;
         $request->uri .= '?' . http_build_query($params);
     } else {
         $request->uri .= '?access_token=' . $this->token;
         $request->body(json_encode($params));
     }
     return $request->send();
 }
开发者ID:interqualitas,项目名称:php-client,代码行数:42,代码来源:Interqualitas.php

示例9: updateVideo

 /**
  * params:
  *  id
  *  is_hidden
  *  is_deleted
  *  video_url
  *
  * @param $videoID
  * @param $params
  * @param $token
  * @param $secure
  * @return bool
  * @throws ResponseClientError
  * @throws ResponseRedirectionError
  * @throws ResponseServerError
  * @throws UnknownResponseCodeException
  */
 public static function updateVideo($videoID, $params, $token, $secure)
 {
     $uri = static::genCompositeUrl(__FUNCTION__, [':video_id' => $videoID], [], $secure);
     $headers = static::getHeaders($token);
     $response = \Httpful\Request::patch($uri)->sendsJson()->body($params)->addHeaders($headers)->send();
     static::checkCode($response->meta_data['http_code'], $response->body);
     return $response->body;
 }
开发者ID:awpeak,项目名称:rutuber,代码行数:25,代码来源:Request.php


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