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


PHP Client::delete方法代码示例

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


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

示例1: delete

 /**
  * @param string $uri
  * @return bool
  */
 private function delete($uri)
 {
     try {
         $this->httpClient->delete($uri)->send();
     } catch (Exception $e) {
         echo $e->getMessage();
         return false;
     }
     return true;
 }
开发者ID:simon-barton,项目名称:KairosDB-Client,代码行数:14,代码来源:Client.php

示例2: deleteCustomer

 /**
  * Send Delete Customer Request
  * @param $id
  * @return Response
  */
 public function deleteCustomer($id)
 {
     try {
         $response = $this->client->delete('/api/v1/customers/' . $id, null, null, array('auth' => $this->auth))->send();
     } catch (RequestException $e) {
         $response = $e->getResponse();
     }
     return new Response($response->getStatusCode(), $response->getReasonPhrase());
 }
开发者ID:Seekube,项目名称:php-customerio,代码行数:14,代码来源:Request.php

示例3: request

 private function request($method, $path, $params = array())
 {
     $url = $this->api . rtrim($path, '/') . '/';
     // Using Guzzle library ---------------------------------
     $client = new Client($url, array('ssl.certificate_authority' => false, 'curl.options' => array('CURLOPT_CONNECTTIMEOUT' => 30)));
     // headers
     $headers = array('Connection' => 'close', 'User-Agent' => 'PHPPlivo');
     if (!strcmp($method, "POST")) {
         $request = $client->post('', $headers, json_encode($params));
         $request->setHeader('Content-type', 'application/json');
     } else {
         if (!strcmp($method, "GET")) {
             $request = $client->get('', $headers, $params);
             $request->getQuery()->merge($params);
         } else {
             if (!strcmp($method, "DELETE")) {
                 $request = $client->delete('', $headers, $params);
                 $request->getQuery()->merge($params);
             }
         }
     }
     $request->setAuth($this->auth_id, $this->auth_token);
     $response = $request->send();
     $responseData = $response->json();
     $status = $response->getStatusCode();
     return array("status" => $status, "response" => $responseData);
 }
开发者ID:Ramya-Raghu,项目名称:plivo-php,代码行数:27,代码来源:plivo.php

示例4: delete

 /**
  * @param string $id
  */
 public function delete($id)
 {
     $url = $this->getConnectionUrl($id);
     $request = $this->client->delete($this->client->getBaseUrl() . $url, $this->HEADERS);
     $response = $request->send();
     $this->statusCodeValidator->validate(200, $url, $request, $response);
 }
开发者ID:janus-ssp,项目名称:client,代码行数:10,代码来源:ConnectionRepository.php

示例5: stop

 /**
  * Stop running the node.js server
  */
 public function stop()
 {
     if (!$this->isRunning()) {
         return false;
     }
     $this->running = false;
     $this->client->delete('guzzle-server')->send();
 }
开发者ID:carlesgutierrez,项目名称:libreobjet.org,代码行数:11,代码来源:Server.php

示例6: stop

 /**
  * Stop running the node.js server
  *
  * @return bool Returns TRUE on success or FALSE on failure
  * @throws RuntimeException
  */
 public function stop()
 {
     if (!$this->isRunning()) {
         return false;
     }
     $this->running = false;
     return $this->client->delete('guzzle-server')->send()->getStatusCode() == 200;
 }
开发者ID:creazy412,项目名称:vmware-win10-c65-drupal7,代码行数:14,代码来源:Server.php

示例7: httpDelete

 /**
  * Performs an HTTP DELETE on a URI. The result can be read from
  * $this->response* variables.
  *
  * This method is named httpDelete() to avoid a name clash with objects that inherit
  * from this one, which usually have a delete() method.
  *
  * @param string $uri
  * @param string $accept
  * @param array $custom_headers
  * @param array $options
  */
 public function httpDelete($uri = null, $accept = 'application/json; charset=utf-8', array $custom_headers = array(), array $options = array())
 {
     $headers = array('accept' => $accept);
     foreach ($custom_headers as $key => $value) {
         $headers[strtolower($key)] = $value;
     }
     $request = $this->client->delete($uri, $headers, null, $options);
     $this->exec($request);
 }
开发者ID:nevetS,项目名称:flame,代码行数:21,代码来源:APIObject.php

示例8: request

 /**
  * @inheritdoc
  */
 public function request($url, $http_headers = array(), $method = 'GET', $post_data = '')
 {
     // Remove oauth parameters from query string. They are not used by the
     // CultuurNet webservices and only clutter our debug log.
     //preg_match_all('/(?<=[?|&])oauth_.*?[&$]/', $url, $matches);
     $url = preg_replace('/(?<=[?|&])oauth_.*?[&$]/', '', $url);
     switch ($method) {
         case 'GET':
             $request = $this->client->get($url);
             break;
         case 'POST':
             if (is_array($post_data)) {
                 // $post_data contains file multipart/form-data, including file data.
                 // Unfortunately the interfaces of Guzzle\Http and CultureFeed_HttpClient are
                 // incompatible here, so we need to fall back to CultureFeed_HttpClient behavior.
                 return parent::request($url, $http_headers, $method, $post_data);
             } else {
                 $request = $this->client->post($url, null, $post_data);
             }
             break;
         case 'DELETE':
             $request = $this->client->delete($url);
             break;
         default:
             throw new Exception('Unsupported HTTP method ' . $method);
     }
     $request->getQuery()->useUrlEncoding(true);
     foreach ($http_headers as $header) {
         list($name, $value) = explode(':', $header, 2);
         $request->addHeader($name, $value);
     }
     // Ensure by default we indicate a Content-Type of
     // application/x-www-form-urlencoded for requests containing a body.
     if ($request instanceof EntityEnclosingRequestInterface && !$request->hasHeader('Content-Type') && empty($request->getPostFiles())) {
         $request->setHeader('Content-Type', 'application/x-www-form-urlencoded');
     }
     try {
         $response = $request->send();
     } catch (BadResponseException $e) {
         $response = $e->getResponse();
     }
     $culturefeedResponse = new CultureFeed_HttpResponse($response->getStatusCode(), $response->getBody(true));
     return $culturefeedResponse;
 }
开发者ID:cultuurnet,项目名称:culturefeed-http-guzzle,代码行数:47,代码来源:HttpClient.php

示例9: testErrorHandling

 public function testErrorHandling()
 {
     $this->client->delete('/_all')->send();
     $response = $this->client->post('/_expectation', null, ['matcher' => ''])->send();
     $this->assertSame(417, $response->getStatusCode());
     $this->assertSame('POST data key "matcher" must be a serialized list of closures', (string) $response->getBody());
     $response = $this->client->post('/_expectation', null, ['matcher' => ['foo']])->send();
     $this->assertSame(417, $response->getStatusCode());
     $this->assertSame('POST data key "matcher" must be a serialized list of closures', (string) $response->getBody());
     $response = $this->client->post('/_expectation', null, [])->send();
     $this->assertSame(417, $response->getStatusCode());
     $this->assertSame('POST data key "response" not found in POST data', (string) $response->getBody());
     $response = $this->client->post('/_expectation', null, ['response' => ''])->send();
     $this->assertSame(417, $response->getStatusCode());
     $this->assertSame('POST data key "response" must be a serialized Symfony response', (string) $response->getBody());
     $response = $this->client->post('/_expectation', null, ['response' => serialize(new Response()), 'limiter' => 'foo'])->send();
     $this->assertSame(417, $response->getStatusCode());
     $this->assertSame('POST data key "limiter" must be a serialized closure', (string) $response->getBody());
 }
开发者ID:internations,项目名称:http-mock,代码行数:19,代码来源:AppIntegrationTest.php

示例10: makeRequest

 /**
  * {@inheritdoc}
  */
 public function makeRequest()
 {
     $client = new Client();
     $request = $client->delete($this->url);
     $response = $request->send();
     if (!in_array($response->getStatusCode(), array(200))) {
         throw new \ErrorException($response->getMessage());
     }
     return true;
 }
开发者ID:adezandee,项目名称:shopify-bundle,代码行数:13,代码来源:DeleteJson.php

示例11: deleteProgram

 /**
  * Remove the reasoner program with the given name from the Marmotta knowledge base.
  * @param $name
  */
 public function deleteProgram($name)
 {
     $client = new Client();
     $request = $client->delete($this->getServiceUrl($name), array("User-Agent" => "Marmotta Client Library (PHP)"));
     // set authentication if given in configuration
     if (!is_null($this->config->getUsername())) {
         $request->setAuth($this->config->getUsername(), $this->config->getPassword());
     }
     $response = $request->send();
 }
开发者ID:ximdex,项目名称:marmotta-client,代码行数:14,代码来源:ReasonerClient.php

示例12: send

 public function send(Postmaster_TransportModel $model)
 {
     if (!empty($this->settings->url)) {
         $headers = $this->settings->headers;
         try {
             $client = new Client();
             switch ($this->settings->action) {
                 case 'get':
                     $request = $client->get($this->settings->url, $headers);
                     $query = $request->getQuery();
                     foreach ($this->settings->postVars as $var) {
                         $query->add($var['name'], $var['value']);
                     }
                     break;
                 case 'post':
                     $request = $client->post($this->settings->url, $this->settings->getHeaders(), $this->settings->getRequestVars());
                     break;
                 case 'put':
                     $request = $client->put($this->settings->url, $this->settings->getHeaders(), $this->settings->getRequestVars());
                     break;
                 case 'delete':
                     $request = $client->delete($this->settings->url, $this->settings->getHeaders());
                     break;
             }
             $response = $request->send();
             $model->addData('responseString', (string) $response->getBody());
             $model->addData('responseJson', json_decode($model->getData('responseString')));
             return $this->success($model);
         } catch (ClientErrorResponseException $e) {
             $response = (string) $e->getResponse()->getBody();
             $json = json_decode($response);
             $model->addData('responseString', $response);
             if (is_object($json) && isset($json->errors)) {
                 if (!is_array($json->errors)) {
                     $json->errors = (array) $json->errors;
                 }
                 $model->addData('responseJson', $json);
                 return $this->failed($model, 400, $json->errors);
             } else {
                 $model->addData('responseJson', array($response));
                 return $this->failed($model, 400, array($response));
             }
         } catch (\Exception $e) {
             $error = $e->getMessage();
             $json = !is_array($error) ? array('title' => $error) : $error;
             $model->addData('responseString', $error);
             $model->addData('responseJson', $json);
             return $this->failed($model, 400, $json);
         }
     }
     return $this->failed($model, 400, array(\Craft::t('The ping url is empty.')));
 }
开发者ID:codeforamerica,项目名称:oakland-beta,代码行数:52,代码来源:HttpRequestService.php

示例13: destroyData

 public static function destroyData(Event $event)
 {
     $io = $event->getIO();
     if (!$event->isDevMode()) {
         $io->write('This script is only supported in development mode. Exiting.');
         return;
     }
     $destroy_data = $io->askConfirmation('<options=bold>Are you sure you want to destroy all local data? [y,N]: </>', false);
     if (true === $destroy_data) {
         $client = new Client();
         $client->setDefaultOption('exceptions', false);
         $es_indices = self::DEFAULT_PROJECT_NAME . '.*';
         $couch_event_db = self::DEFAULT_PROJECT_NAME . '%2Bdomain_events';
         $couch_process_db = self::DEFAULT_PROJECT_NAME . '%2Bprocess_states';
         $io->write('-> deleting Elasticsearch indices "' . $es_indices . '"');
         $client->delete('http://localhost:9200/' . $es_indices)->send();
         $io->write('-> deleting CouchDb database "' . $couch_event_db . '"');
         $client->delete('http://127.0.0.1:5984/' . $couch_event_db)->send();
         $io->write('-> deleting CouchDb database "' . $couch_process_db . '"');
         $client->delete('http://127.0.0.1:5984/' . $couch_process_db)->send();
     }
     return $destroy_data;
 }
开发者ID:honeybee,项目名称:honeybee-agavi-cmf-demo,代码行数:23,代码来源:DemoProjectHandler.php

示例14: request

 /**
  * Send signed HTTP requests to the API server.
  *
  * @param string $method HTTP method (GET, POST, PUT or DELETE)
  * @param string $path   Request path
  * @param array  $params Additional request parameters
  *
  * @return string The API server's response
  *
  * @throws ApiException  if an API error occurs
  * @throws HttpException if the request fails
  */
 private function request($method, $path, array $params)
 {
     // sign the request parameters
     $signer = PandaSigner::getInstance($this->cloudId, $this->account);
     $params = $signer->signParams($method, $path, $params);
     // ensure to use relative paths
     if (0 === strpos($path, '/')) {
         $path = substr($path, 1);
     }
     // append request parameters to the URL
     if ('GET' === $method || 'DELETE' === $method) {
         $path .= '?' . http_build_query($params);
     }
     // prepare the request
     $request = null;
     switch ($method) {
         case 'GET':
             $request = $this->guzzleClient->get($path);
             break;
         case 'DELETE':
             $request = $this->guzzleClient->delete($path);
             break;
         case 'PUT':
             $request = $this->guzzleClient->put($path, null, $params);
             break;
         case 'POST':
             $request = $this->guzzleClient->post($path, null, $params);
             break;
     }
     // and execute it
     try {
         $response = $request->send();
     } catch (\Exception $e) {
         // throw an exception if the http request failed
         throw new HttpException($e->getMessage(), $e->getCode());
     }
     // throw an API exception if the API response is not valid
     if ($response->getStatusCode() < 200 || $response->getStatusCode() > 207) {
         $decodedResponse = json_decode($response->getBody(true));
         $message = $decodedResponse->error . ': ' . $decodedResponse->message;
         throw new ApiException($message, $response->getStatusCode());
     }
     return $response->getBody(true);
 }
开发者ID:xabbuh,项目名称:panda-client,代码行数:56,代码来源:HttpClient.php

示例15: request

 private function request($url, array $body = array(), $method)
 {
     $json = json_encode($body);
     $client = new Client($this->baseUrl);
     switch ($method) {
         case 'GET':
             $request = $client->get($url, NULL, $json);
             break;
         case 'PUT':
             $request = $client->put($url, NULL, $json);
             break;
         case 'POST':
             $request = $client->post($url, NULL, $json);
             break;
         case "DELETE":
             $request = $client->delete($url, NULL, $json);
             break;
     }
     $request = $request->setAuth($this->apiEmail, $this->apiKey);
     try {
         $response = $request->send();
         $body = $response->getBody();
         $headers = $response->getHeaders();
     } catch (HttpException $e) {
         $response = json_decode($e->getResponse()->getBody(), true);
         throw new APIException($response['error']['message'], $response['error']['code'], isset($response['error']['reason']) ? $response['error']['reason'] : '', $e);
     }
     return new ApiResponse($headers, json_decode($body, true));
 }
开发者ID:myerp,项目名称:myerp-php-api-client,代码行数:29,代码来源:Api.php


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