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


PHP Client::delete方法代码示例

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


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

示例1: execute

 public function execute($client = null)
 {
     if ($client == null) {
         $client = new GuzzleClient();
     }
     $url = $this->protocol . '://' . $this->hostname . $this->path;
     switch ($this->verb) {
         case 'get':
             $request = $client->get($url);
             break;
         case 'post':
             $request = $client->post($url);
             break;
         case 'put':
             $request = $client->put($url);
             break;
         case 'delete':
             $request = $client->delete($url);
             break;
     }
     return new Response($request->send());
 }
开发者ID:eher,项目名称:ldd,代码行数:22,代码来源:Request.php

示例2: sendDeleteRequest

 /**
  * Send DELETE request to API resource
  *
  * @param string $resource
  * @return array
  */
 protected function sendDeleteRequest($resource)
 {
     $client = new Client();
     $request = $client->delete($this->getServiceUrl($resource), array('Authorization' => $this->getOauthData(), 'Accept' => 'application/x-yametrika+json', 'Content-Type' => 'application/x-yametrika+json'));
     $response = $this->sendRequest($request)->json();
     return $response;
 }
开发者ID:9kopb,项目名称:yandex-php-library,代码行数:13,代码来源:MetricaClient.php

示例3: dequeue

 public static function dequeue($job, $data)
 {
     $callback_url = $data['callback_url'];
     $method = strtoupper($data['callback_method']);
     $payload = unserialize(base64_decode($data['callback_payload_base64']));
     if (empty($callback_url)) {
         Log::warning('Empty callback URL');
         return FALSE;
     }
     $client = new HttpClient();
     if ($method == 'GET') {
         $request = $client->get($callback_url);
     } elseif ($method == 'POST') {
         $request = $client->post($callback_url, array(), $payload);
     } elseif ($method == 'PUT') {
         $request = $client->put($callback_url, array(), $payload);
     } elseif ($method == 'DELETE') {
         $request = $client->delete($callback_url);
     } elseif ($method == 'UPDATE') {
         $request = $client->update($callback_url);
     } elseif ($method == 'PATCH') {
         $request = $client->patch($callback_url);
     } else {
         QueuedHttpClient::logFailedCallback($job, $data, ['success' => false, 'message' => 'Unsupported method: ' . $method], 'hard');
         return FALSE;
     }
     try {
         $response = $request->send();
         if ($response->getStatusCode() != 200) {
             if ($job->attempts() > 60) {
                 QueuedHttpClient::logFailedCallback($job, $data, $response, 'hard');
                 $job->delete();
             } else {
                 QueuedHttpClient::logFailedCallback($job, $data, $response, 'soft');
                 $job->release(60);
             }
             return $response;
         }
         // request probably successful, delete from queue
         $job->delete();
         return $response;
         // these exceptions are broken out here because perhaps we want to
         // treat them differently in deciding whether to requeue or not
     } catch (CurlException $e) {
         // curl network and low-level exceptions
         QueuedHttpClient::retryLaterOrDelete($job, $data, get_class($e) . ": " . $e->getResponse(), 60, 60 * 24);
         // retry every minute for up to 24 hours
     } catch (Guzzle\Http\Exception\ClientErrorResponseException $e) {
         // server 4xx exceptions
         QueuedHttpClient::retryLaterOrDelete($job, $data, get_class($e) . ": " . $e->getResponse(), 60, 60);
         // retry every minute for up to an hour
     } catch (Guzzle\Http\Exception\ServerErrorResponseException $e) {
         // server 5xx exceptions
         QueuedHttpClient::retryLaterOrDelete($job, $data, get_class($e) . ": " . $e->getResponse(), 60, 60 * 24);
         // retry every minute for up to 24 hours
     } catch (Guzzle\Common\Exception\RuntimeException $e) {
         // result most likely wasn't in JSON format
         QueuedHttpClient::retryLaterOrDelete($job, $data, get_class($e) . ": " . $e->getMessage(), 60, 10);
         // retry every minute for up to ten minutes
     } catch (Exception $e) {
         // unknown other error
         QueuedHttpClient::retryLaterOrDelete($job, $data, get_class($e) . ": " . $e->getMessage(), 60, 60 * 24);
         // retry every minute for up to 24 hours
     }
 }
开发者ID:mocavo,项目名称:queued-http-client,代码行数:65,代码来源:QueuedHttpClient.php


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