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