本文整理汇总了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;
}
示例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);
}
示例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;
}
}
示例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();
}
示例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) {
}
}
示例6: testDeleteScheduleFailed
public function testDeleteScheduleFailed()
{
try {
self::$client->delete('/');
$this->fail("Call did not fail");
} catch (ClientException $e) {
$this->assertEquals(400, $e->getCode());
}
}
示例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));
}
示例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"));
}
示例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;
}
示例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);
}
}
示例11: delete
public function delete($resource, $type, $options = [])
{
$options['future'] = true;
return $this->client->delete($resource, $options)->then(function (Response $reponse) {
return $reponse->json();
});
}
示例12: delete
public function delete($url = null, array $options = [])
{
$options = $this->setVerify($options);
$options['query'] = $this->ApiParams;
$this->resetParams();
return parent::delete($url, $options);
}
示例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);
}
示例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;
}
示例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;
}