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


PHP Client::patch方法代码示例

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


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

示例1: getResponse

 private function getResponse($stack, $base_uri, $uri, $data, $httpMethod)
 {
     $middleware = new Oauth1(['consumer_key' => self::CONSUMER_KEY, 'consumer_secret' => self::CONSUMER_SECRET, 'token_secret' => self::TOKEN_SECRET]);
     //'auth' => ['user_name', 'pass_name'], // when using username & password
     $options = ['auth' => 'oauth', 'debug' => false, 'headers' => ['Accept' => 'application/hal+json', 'Content-Type' => 'application/hal+json'], 'body' => json_encode($data)];
     $stack->push($middleware);
     $client = new Client(['base_uri' => $base_uri, 'handler' => $stack]);
     $response = false;
     switch ($httpMethod) {
         case self::HTTP_GET:
             $response = $client->get($uri, $options);
             break;
         case self::HTTP_POST:
             $response = $client->post($uri, $options);
             break;
         case self::HTTP_PUT:
             $response = $client->put($uri, $options);
             break;
         case self::HTTP_PATCH:
             $response = $client->patch($uri, $options);
             break;
         case self::HTTP_DELETE:
             $response = $client->delete($uri, $options);
             break;
     }
     return $response;
 }
开发者ID:suffrajet,项目名称:gdoctor,代码行数:27,代码来源:Guzzle.php

示例2: patch

 /**
  * @param string $url
  * @param array $options
  * @throws GuzzleException
  * @return Response
  */
 public function patch($url, array $options = [])
 {
     if (strpos($url, 'http') !== 0) {
         $url = $this->baseUrl . '/' . $this->collection . '/' . ltrim($url, '/');
     }
     return new Response($this, $this->client->patch($url, $options));
 }
开发者ID:opensoft,项目名称:tfs-rest-api,代码行数:13,代码来源:ClientHelper.php

示例3: patch

 public function patch($resource, $data, $type, $options = [])
 {
     $options['json'] = $data;
     $options['headers'] = ['Content-Type' => 'application/json'];
     $content = $this->client->patch($resource, $options)->getBody()->getContents();
     return $this->deserialize($content, $type);
 }
开发者ID:italolelis,项目名称:wunderlist,代码行数:7,代码来源:GuzzleAdapter.php

示例4: patch

 public function patch($resource, $data, $type, $options = [])
 {
     $options['future'] = true;
     $options['json'] = $data;
     $options['headers'] = ['Content-Type' => 'application/json'];
     return $this->client->patch($resource, $options)->then(function (Response $reponse) {
         return $reponse->getBody()->getContents();
     })->then(function ($content) use($type) {
         return $this->deserialize($content, $type);
     });
 }
开发者ID:italolelis,项目名称:wunderlist,代码行数:11,代码来源:AsyncGuzzleAdapter.php

示例5: testNoCacheOtherMethod

 public function testNoCacheOtherMethod()
 {
     $this->client->post("anything");
     $response = $this->client->post("anything");
     $this->assertEquals("", $response->getHeaderLine("X-Cache"));
     $this->client->put("anything");
     $response = $this->client->put("anything");
     $this->assertEquals("", $response->getHeaderLine("X-Cache"));
     $this->client->delete("anything");
     $response = $this->client->delete("anything");
     $this->assertEquals("", $response->getHeaderLine("X-Cache"));
     $this->client->patch("anything");
     $response = $this->client->patch("anything");
     $this->assertEquals("", $response->getHeaderLine("X-Cache"));
 }
开发者ID:royopa,项目名称:guzzle-cache-middleware,代码行数:15,代码来源:BaseTest.php

示例6: testNoCacheOtherMethod

 public function testNoCacheOtherMethod()
 {
     $this->client->post('anything');
     $response = $this->client->post('anything');
     $this->assertEquals(CacheMiddleware::HEADER_CACHE_MISS, $response->getHeaderLine(CacheMiddleware::HEADER_CACHE_INFO));
     $this->client->put('anything');
     $response = $this->client->put('anything');
     $this->assertEquals(CacheMiddleware::HEADER_CACHE_MISS, $response->getHeaderLine(CacheMiddleware::HEADER_CACHE_INFO));
     $this->client->delete('anything');
     $response = $this->client->delete('anything');
     $this->assertEquals(CacheMiddleware::HEADER_CACHE_MISS, $response->getHeaderLine(CacheMiddleware::HEADER_CACHE_INFO));
     $this->client->patch('anything');
     $response = $this->client->patch('anything');
     $this->assertEquals(CacheMiddleware::HEADER_CACHE_MISS, $response->getHeaderLine(CacheMiddleware::HEADER_CACHE_INFO));
 }
开发者ID:kevinrob,项目名称:guzzle-cache-middleware,代码行数:15,代码来源:BaseTest.php

示例7: handle

 /**
  * Send Rename request to slave
  *
  */
 public function handle()
 {
     $client = new Client();
     try {
         $response = $client->patch($this->slave . ApiUrl::$rename . '/' . $this->from . '/' . $this->to . '?token=' . getMasterPassword());
     } catch (\Exception $e) {
     }
 }
开发者ID:phileserver,项目名称:core,代码行数:12,代码来源:RenameFileOnSlave.php

示例8: patch

 /**
  * @param string $uri
  * @param array $data
  * @param array $options
  * @param bool $api
  * @return $this;
  */
 public function patch($uri, array $data = [], array $options = [], $api = true)
 {
     $options = $this->configureOptions($options);
     $uri = $api ? $this->getServiceConfig('api_url') . $uri : $uri;
     $response = $this->client->patch($uri, array_merge($options, ['form_params' => $data]));
     $this->setGuzzleResponse($response);
     return $this;
 }
开发者ID:someline,项目名称:rest-api-client,代码行数:15,代码来源:RestClient.php

示例9: disableEmailObfuscation

 private function disableEmailObfuscation()
 {
     try {
         $response = $this->client->patch('zones/' . $this->zoneId . '/settings/email_obfuscation', ['json' => ['value' => 'off']]);
         return $response->json(['object' => true])->result;
     } catch (Exception $e) {
         throw $this->createCloudflareException($e);
     }
 }
开发者ID:adhikjoshi,项目名称:D-provider,代码行数:9,代码来源:CloudflareAPI.php

示例10: patch

 /**
  * @param $url
  * @param $version
  * @param array  $data
  * @param string $bodyEncoding
  *
  * @return \GuzzleHttp\Message\FutureResponse|\GuzzleHttp\Message\ResponseInterface|\GuzzleHttp\Ring\Future\FutureInterface|null
  */
 private function patch($url, $version, array $data = [], $bodyEncoding = 'json')
 {
     $requestOptions = $this->getPostRequestOptions($version, $data, $bodyEncoding);
     $response = $this->client->patch($url, $requestOptions);
     if (200 !== $response->getStatusCode()) {
         throw new \LogicException('An error occurred when trying to POST data to MR API');
     }
     return $response;
 }
开发者ID:nlegoff,项目名称:api-php-client,代码行数:17,代码来源:Client.php

示例11: patch

 /**
  * @param string $path
  * @param array  $options
  *
  * @throws ClientException
  *
  * @return string
  */
 public function patch($path, array $options = [])
 {
     $options = array_merge($this->options, $options);
     try {
         /** @var Response $result */
         $result = $this->guzzle->patch($path, $options);
     } catch (RequestException $requestException) {
         throw new ClientException('Could not update.', 0, $requestException);
     }
     return $result->getBody()->getContents();
 }
开发者ID:danielbadura,项目名称:redmine-api-client,代码行数:19,代码来源:GuzzleAdapter.php

示例12: patch

 public function patch($uri, array $body)
 {
     $this->lastRequestBody = $body;
     try {
         $this->lastResponse = $this->client->patch($uri, ['json' => $body, 'headers' => $this->headers]);
     } catch (RequestException $e) {
         $this->lastResponse = $e->getResponse();
     } finally {
         $this->lastResponseBody = $this->lastResponse->getBody()->getContents();
     }
 }
开发者ID:interactive-solutions,项目名称:zf-behat,代码行数:11,代码来源:ApiClient.php

示例13: completeTask

 /**
  * Completes a task
  *
  * @param int $taskId
  * @param int $revision
  * 
  * @return array
  */
 public function completeTask($taskId, $revision)
 {
     if (!is_numeric($taskId)) {
         throw new \InvalidArgumentException('The list id must be numeric');
     } elseif (!is_numeric($revision)) {
         throw new \InvalidArgumentException('The revision must be numeric');
     }
     $response = $this->guzzle->patch('tasks/' . $taskId, ['body' => json_encode(['revision' => (int) $revision, 'completed' => true])]);
     $this->checkResponseStatusCode($response, 200);
     return json_decode($response->getBody(), true);
 }
开发者ID:AndrewCarterUK,项目名称:wunderlist-api-demo,代码行数:19,代码来源:WunderlistClient.php

示例14: rename

 /**
  * Modify the name of a remote `Node`.
  *
  * @param string $name
  *
  * @return array
  */
 public function rename($name)
 {
     $retval = ['success' => false, 'data' => []];
     $response = self::$httpClient->patch(self::$account->getMetadataUrl() . "nodes/{$this['id']}", ['headers' => ['Authorization' => 'Bearer ' . self::$account->getToken()['access_token']], 'json' => ['name' => $name], 'exceptions' => false]);
     $retval['data'] = json_decode((string) $response->getBody(), true);
     if ($response->getStatusCode() === 200) {
         $retval['success'] = true;
         $this->replace($retval['data']);
         $this->save();
     }
     return $retval;
 }
开发者ID:nikkiii,项目名称:clouddrive-php,代码行数:19,代码来源:Node.php

示例15: method

 private function method($object, $url, $name = 'post', $args = null)
 {
     try {
         if (is_array($args)) {
             $url = array($url, $args);
         }
         switch ($name) {
             case 'post':
                 $response = $this->client->post($url, array('body' => $this->object[$object]));
                 break;
             case 'patch':
                 $response = $this->client->patch($url, array('body' => $this->object[$object]));
                 break;
             default:
                 throw new \Exception("Method isn't defined");
         }
         //Fetch recent created record
         $this->object_created[$object] = $this->client->get($response->getHeader('location'))->json();
     } catch (ClientException $e) {
         var_dump($e->getResponse()->json());
         \PHPUnit_Framework_TestCase::fail('CLIENT: ' . $e->getMessage());
     }
 }
开发者ID:bixlabs,项目名称:concepto-sises,代码行数:23,代码来源:RestContext.php


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