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