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


PHP Client::patch方法代码示例

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


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

示例1: patchDoctorService

 /**
  * @param int           $facilityId
  * @param int           $doctorId
  * @param DoctorService $doctorService
  *
  * @return DoctorService
  */
 public function patchDoctorService($facilityId, $doctorId, $doctorService)
 {
     $request = $this->client->patch(['facilities/{facilityId}/doctors/{doctorId}/services/{doctorServiceId}', ['facilityId' => $facilityId, 'doctorId' => $doctorId, 'doctorServiceId' => $doctorService->getId()]], [], $this->serializer->serialize($doctorService, 'json', SerializationContext::create()->setGroups(['patch'])));
     /** @var DoctorService $newDoctorService */
     $newDoctorService = $this->authorizedRequest($request, DoctorService::class, DeserializationContext::create()->setGroups(['get']));
     return $newDoctorService;
 }
开发者ID:umitakkaya,项目名称:sample-api-client,代码行数:14,代码来源:DPClient.php

示例2: patchUser

 /**
  * Edit an user fields.
  *
  * @param int $id
  * @param array $fields
  *
  * @return mixed
  */
 public function patchUser($id, array $fields)
 {
     $request = $this->client->patch($this->customer['url'] . '/api/users/' . $id);
     $request->setAuth($this->customer['username'], $this->customer['password']);
     $request->setBody(json_encode($fields));
     $response = $request->send();
     return json_decode($response->getBody(true));
 }
开发者ID:CanalTP,项目名称:NavitiaIoApiComponent,代码行数:16,代码来源:NavitiaIoApiService.php

示例3: patch

 function patch($endpoint, $data = array())
 {
     try {
         $client = new Client();
         $bearerAuth = new BearerAuth($this->token);
         $client->addSubscriber($bearerAuth);
         $request = $client->patch($this->base_url . $endpoint, array(), json_encode($data, JSON_FORCE_OBJECT));
         $request->addHeader('Content-Type', 'application/json');
         $response = $request->send();
         return $response->json();
     } catch (BearerErrorResponseException $e) {
         return $e->getMessage();
     } catch (BadResponseException $e) {
         return $e->getMessage();
     }
 }
开发者ID:uprise10,项目名称:moneybird-test,代码行数:16,代码来源:Handler.php

示例4: patch

 /**
  * Patch (partial update) an object at a set location ($path)
  * @param string $path the path to post this object to.
  * @param object $object the object to be posted to given path
  * @param array $headers an array of headers to send with the request
  * @return \DrestClient\Response $response Response object with a populated representation instance
  * @throws ErrorException upon the return of any error document from the server
  */
 public function patch($path, &$object, array $headers = array())
 {
     $representation = $this->getRepresentationInstance();
     $representation->update($object);
     $request = $this->transport->patch($path, $headers, $representation->__toString());
     foreach ($this->getVarsFromPath($path) as $key => $value) {
         $request->setPostField($key, $value);
     }
     $request->setHeader('Content-Type', $representation->getContentType());
     try {
         $response = $this->transport->send($request);
     } catch (BadResponseException $exception) {
         throw $this->handleErrorResponse($exception);
     }
     return new Response($representation, $response);
 }
开发者ID:leedavis81,项目名称:drest-client,代码行数:24,代码来源:Client.php

示例5: elseif

             $app['session']->set('error', $e->getResponse()->getStatusCode() . ": " . $e->getResponse()->getReasonPhrase());
             return $app->redirect('../../ui/error');
         }
     }
     // return the response (the json or php file)
     return $response;
 } elseif ($app['session']->get('method') == 'get') {
     $title = $title . "for getting";
     $app['session']->set('userget', $formdata['Username']);
     $app['session']->set('pswdget', $formdata['Password']);
 } elseif ($app['session']->get('method') == 'patch') {
     $title = $title . "for editing";
     $app['session']->set('userpatch', $formdata['Username']);
     $app['session']->set('pswdpatch', $formdata['Password']);
     try {
         $request = $client->patch($app['session']->get('path'), null, $app['session']->get('body'))->setAuth($formdata['Username'], $formdata['Password']);
         $response = $request->send();
     } catch (ClientErrorResponseException $e) {
         if ($e->getResponse()->getStatusCode() == 401) {
             return $app->redirect($hostname . 'ui/authentication');
         } else {
             $app['session']->set('error', $e->getResponse()->getStatusCode() . ": " . $e->getResponse()->getReasonPhrase());
             return $app->redirect('../../ui/error');
         }
     }
 } elseif ($app['session']->get('method') == 'put') {
     $title = $title . "for putting";
     $app['session']->set('userput', $formdata['Username']);
     $app['session']->set('pswdput', $formdata['Password']);
     try {
         $request = $client->put($app['session']->get('path'), null, $app['session']->get('body'))->setAuth($formdata['Username'], $formdata['Password']);
开发者ID:tdt,项目名称:ui,代码行数:31,代码来源:authentication.php

示例6: testClientHasHelperMethodsForCreatingRequests

 public function testClientHasHelperMethodsForCreatingRequests()
 {
     $url = $this->getServer()->getUrl();
     $client = new Client($url . 'base');
     $this->assertEquals('GET', $client->get()->getMethod());
     $this->assertEquals('PUT', $client->put()->getMethod());
     $this->assertEquals('POST', $client->post()->getMethod());
     $this->assertEquals('HEAD', $client->head()->getMethod());
     $this->assertEquals('DELETE', $client->delete()->getMethod());
     $this->assertEquals('OPTIONS', $client->options()->getMethod());
     $this->assertEquals('PATCH', $client->patch()->getMethod());
     $this->assertEquals($url . 'base/abc', $client->get('abc')->getUrl());
     $this->assertEquals($url . 'zxy', $client->put('/zxy')->getUrl());
     $this->assertEquals($url . 'zxy?a=b', $client->post('/zxy?a=b')->getUrl());
     $this->assertEquals($url . 'base?a=b', $client->head('?a=b')->getUrl());
     $this->assertEquals($url . 'base?a=b', $client->delete('/base?a=b')->getUrl());
 }
开发者ID:carlesgutierrez,项目名称:libreobjet.org,代码行数:17,代码来源:ClientTest.php

示例7: array

 // getting the data from the form
 $formdata = $form->getData();
 // making array for the body of the put request
 $body = array();
 foreach ($parameterstobechanged as $key => $value) {
     $body[$key] = $formdata[$key];
 }
 // initializing a new client
 $client2 = new Client();
 try {
     $path = $hostname . "tdtadmin/resources/" . $app['session']->get('pathtoresource');
     // the put request
     // checking if once in a session time a username and password is given to authorise for patching
     // if not, try without authentication
     if ($app['session']->get('userpatch') == null || $app['session']->get('pswdpatch') == null) {
         $request = $client2->patch($path, null, $body);
     } else {
         $request = $client2->patch($path, null, $body)->setAuth($app['session']->get('userpatch'), $app['session']->get('pswdpatch'));
     }
     $response = $request->send();
 } catch (ClientErrorResponseException $e) {
     // if tried with authentication and it failed
     // or when tried without authentication and authentication is needed
     if ($e->getResponse()->getStatusCode() == 401) {
         // necessary information is stored in the session object, needed to redo the request after authentication
         $app['session']->set('method', 'patch');
         $app['session']->set('path', $path);
         $app['session']->set('body', $body);
         $app['session']->set('redirect', $hostname . 'ui/package');
         $app['session']->set('referer', $hostname . 'ui/resource/edit');
         return $app->redirect('../../ui/authentication');
开发者ID:tdt,项目名称:ui,代码行数:31,代码来源:editresource.php

示例8: executeRequest

 /**
  * @param Client $client
  * @param string $method
  * @param string $url
  * @param array $parameters
  * @param array $options
  * @param string|null $payload
  * @return \Guzzle\Http\Message\Response
  * @throws \Exception
  */
 protected function executeRequest(Client $client, $method, $url, array $parameters, array $options, $payload = null)
 {
     switch ($method) {
         case 'get':
             $request = $client->get($url, $parameters, $options);
             break;
         case 'post':
         case 'upload':
             $request = $client->post($url, $parameters, $payload, $options);
             break;
         case 'put':
             $request = $client->put($url, $parameters, $payload, $options);
             break;
         case 'patch':
             $request = $client->patch($url, $parameters, $payload, $options);
             break;
         case 'delete':
             $request = $client->delete($url, $parameters, $payload, $options);
             break;
         default:
             throw new \Exception('Invalid method');
             break;
     }
     return $request->send();
 }
开发者ID:stamplia,项目名称:stamplia-php,代码行数:35,代码来源:ApiClient.php


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