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


PHP Client::delete方法代码示例

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


在下文中一共展示了Client::delete方法的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: removeObject

 public function removeObject($object)
 {
     $identifier = $this->getObjectIdentifier($object);
     $class = $this->objectManager->getClassMetadata(get_class($object));
     $url = sprintf('%s/%s', $this->url, $identifier[$class->identifier[0]]);
     $this->client->delete($url);
 }
开发者ID:basuritas-php,项目名称:skeleton-mapper,代码行数:7,代码来源:HttpObjectPersister.php

示例3: makeHttpRequest

 function makeHttpRequest($method, $url, $apiRequest = null, $queryString = null)
 {
     $urlEndPoint = $this->apiConfiguration->getDefaultEndPoint() . '/' . $url;
     $data = ['headers' => ['Authorization' => 'Bearer ' . $this->apiConfiguration->getAccessToken()], 'json' => $apiRequest, 'query' => $queryString];
     try {
         switch ($method) {
             case 'post':
                 $response = $this->guzzle->post($urlEndPoint, $data);
                 break;
             case 'put':
                 $response = $this->guzzle->put($urlEndPoint, $data);
                 break;
             case 'delete':
                 $response = $this->guzzle->delete($urlEndPoint, $data);
                 break;
             case 'get':
                 $response = $this->guzzle->get($urlEndPoint, $data);
                 break;
             default:
                 throw new \Exception('Missing request method!');
         }
         if (in_array(current($response->getHeader('Content-Type')), ['image/png', 'image/jpg'])) {
             $result = $response->getBody()->getContents();
         } else {
             $result = json_decode($response->getBody(), true);
         }
         return $result;
     } catch (ConnectException $c) {
         throw $c;
     } catch (RequestException $e) {
         throw $e;
     }
 }
开发者ID:turboship,项目名称:api-php,代码行数:33,代码来源:HttpRequest.php

示例4: retrieveByCredentials

 /**
  * Retrieve a user by the given credentials.
  *
  * @param array $credentials
  *
  * @return \Magister\Services\Database\Elegant\Model|null
  */
 public function retrieveByCredentials(array $credentials)
 {
     $body = ['body' => $credentials];
     $this->client->delete('sessies/huidige');
     $this->client->post('sessies', $body);
     return $this->retrieveByToken();
 }
开发者ID:JeroenJochems,项目名称:Magister,代码行数:14,代码来源:ElegantUserProvider.php

示例5: afterScenario

 /** @AfterScenario */
 public function afterScenario()
 {
     $davUrl = $this->baseUrl . '/remote.php/dav/addressbooks/users/admin/MyAddressbook';
     try {
         $this->client->delete($davUrl, ['auth' => ['admin', 'admin']]);
     } catch (\GuzzleHttp\Exception\ClientException $e) {
     }
 }
开发者ID:gvde,项目名称:core,代码行数:9,代码来源:CardDavContext.php

示例6: testDeleteScheduleFailed

 public function testDeleteScheduleFailed()
 {
     try {
         self::$client->delete('/');
         $this->fail("Call did not fail");
     } catch (ClientException $e) {
         $this->assertEquals(400, $e->getCode());
     }
 }
开发者ID:GafaMX,项目名称:dev_funciones_basicas,代码行数:9,代码来源:CampaignScheduleServiceUnitTest.php

示例7: 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

示例8: 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

示例9: delete

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Retorna status da deleção  200=OK
  */
 public function delete($id)
 {
     $client = new GuzzleHttp\Client();
     $request = $client->delete($this->_apiBase . $this->_className . '/' . $id . '?access_token=' . $this->_apiKey);
     $response = $request->getBody();
     return $response;
 }
开发者ID:fnietto,项目名称:granatum,代码行数:13,代码来源:GranatumBase.php

示例10: handle

 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     DB::connection()->reconnect();
     $pin = Pin::findOrFail($this->pinId);
     $client = new Client(['base_uri' => 'https://timeline-api.getpebble.com/v1/user/pins/']);
     try {
         $response = $client->delete($pin->pin_id, ['headers' => ['Content-Type' => 'application/json', 'X-User-Token' => $this->timelineToken]]);
         if ($response->getStatusCode() === 200) {
             $pin->status = 'deleted';
             $pin->status_code = $response->getStatusCode();
             $pin->response = $response->getBody();
             $pin->update();
         } else {
             Log::error('Pin Delete Failure - ' . $pin->id . ' due to ' . $response->getStatusCode() . ' - ' . $response->getBody());
         }
     } catch (RequestException $e) {
         $responseCode = $e->getResponse()->getStatusCode();
         $responseBody = $e->getResponse()->getBody();
         Log::error('Pin Delete Failure - API - ' . $pin->id . ' due to ' . $responseCode . ' - ' . $responseBody);
     } catch (TransferException $e) {
         $responseCode = $e->getResponse()->getStatusCode();
         $responseBody = $e->getResponse()->getBody();
         Log::error('Pin Delete Failure - Network - ' . $pin->id . ' due to ' . $responseCode . ' - ' . $responseBody);
     }
 }
开发者ID:kz,项目名称:timetable-pusher-backend,代码行数:30,代码来源:DeletePin.php

示例11: delete

 public function delete($resource, $type, $options = [])
 {
     $options['future'] = true;
     return $this->client->delete($resource, $options)->then(function (Response $reponse) {
         return $reponse->json();
     });
 }
开发者ID:italolelis,项目名称:wunderlist,代码行数:7,代码来源:AsyncGuzzleAdapter.php

示例12: delete

 public function delete($url = null, array $options = [])
 {
     $options = $this->setVerify($options);
     $options['query'] = $this->ApiParams;
     $this->resetParams();
     return parent::delete($url, $options);
 }
开发者ID:seregatte,项目名称:shopify-guzzle-api,代码行数:7,代码来源:Api.php

示例13: request

 private function request($method, $path, $params = array())
 {
     $url = $this->api . rtrim($path, '/') . '/';
     $client = new Client(['base_uri' => $url, 'auth' => [$this->auth_id, $this->auth_token], 'http_errors' => false]);
     if (!strcmp($method, "POST")) {
         $body = json_encode($params, JSON_FORCE_OBJECT);
         try {
             $response = $client->post('', array('headers' => ['Content-type' => 'application/json'], 'body' => $body));
         } catch (ClientException $e) {
             echo $e->getRequest();
             echo $e->getResponse();
         }
     } else {
         if (!strcmp($method, "GET")) {
             try {
                 $response = $client->get('', array('query' => $params));
             } catch (ClientException $e) {
                 echo $e->getRequest();
                 echo $e->getResponse();
             }
         } else {
             if (!strcmp($method, "DELETE")) {
                 try {
                     $response = $client->delete('', array('query' => $params));
                 } catch (ClientException $e) {
                     echo $e->getRequest();
                     echo $e->getResponse();
                 }
             }
         }
     }
     $responseData = json_decode($response->getBody(), true);
     $status = $response->getStatusCode();
     return array("status" => $status, "response" => $responseData);
 }
开发者ID:blackchat,项目名称:plivo-php,代码行数:35,代码来源:plivo.php

示例14: makeRequest

 public static function makeRequest($request, $url, $getRawResponse = false)
 {
     $client = new Client();
     switch ($request->getActionType()) {
         case ActionType::GET:
             if ($getRawResponse) {
                 return $client->get($url);
             } else {
                 $response = GuzzleHelper::getAsset($url);
                 //$client->get($url);
             }
             break;
         case ActionType::DELETE:
             $response = $client->delete($url);
             break;
         case ActionType::PUT:
             $response = $client->put($url);
             break;
         case ActionType::POST:
             $response = $client->post($url);
             break;
         default:
             $response = GuzzleHelper::getAsset($url);
             //$client->get($url);
     }
     return $response;
 }
开发者ID:Poornimagaurav,项目名称:delphinium,代码行数:27,代码来源:GuzzleHelper.php

示例15: remove

 /**
  * Remove an image from docker daemon
  *
  * @param Image   $image   Image to remove
  * @param boolean $force   Force removal of image (default false)
  * @param boolean $noprune Do not remove parent images (default false)
  *
  * @throws \Docker\Exception\UnexpectedStatusCodeException
  *
  * @return ImageManager
  */
 public function remove(Image $image, $force = false, $noprune = false)
 {
     $response = $this->client->delete(['/images/{image}?force={force}&noprune={noprune}', ['image' => $image->__toString(), 'force' => $force, 'noprune' => $noprune, 'wait' => true]]);
     if ($response->getStatusCode() !== "200") {
         throw UnexpectedStatusCodeException::fromResponse($response);
     }
     return $this;
 }
开发者ID:andreyserdjuk,项目名称:docker-php,代码行数:19,代码来源:ImageManager.php


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