本文整理匯總了PHP中Curl\Curl::delete方法的典型用法代碼示例。如果您正苦於以下問題:PHP Curl::delete方法的具體用法?PHP Curl::delete怎麽用?PHP Curl::delete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Curl\Curl
的用法示例。
在下文中一共展示了Curl::delete方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: deleteSubAccount
/**
* @param string $apiKey
* @param string $apiSecret
* @param int $subAccountId
*
* @return AccountResponse
*/
public static function deleteSubAccount($apiKey, $apiSecret, $subAccountId)
{
$apiEndpoint = sprintf('%s/subaccounts/%s', self::API_URL, $subAccountId);
$curl = new Curl();
$curl->delete($apiEndpoint, json_encode(['api_key' => $apiKey, 'api_secret' => $apiSecret]));
return self::parseResponse($curl);
}
示例2: delete
public function delete($url = false, $params = false)
{
if ($url) {
if ($params === false) {
$params = array();
}
$curl = new Curl();
$curl->delete($url, $params);
if ($curl->error) {
return $curl->errorCode . ': ' . $curl->errorMessage;
} else {
return $curl->response;
}
}
return false;
}
示例3: call
/**
* Make API-call
*/
private function call($method, $uri, $getParams = array(), $postParams = array(), $authMethod = 'basic')
{
$uri = $this->apiEndpoint . $uri;
$getParams = array_merge($this->apiGetParams, $getParams);
// Filter empty params
$getParams = array_filter($getParams, function ($var) {
return !empty($var);
});
// CURL Stuff
$this->applyCurlOptions($authMethod);
// Do Request
switch ($method) {
case 'get':
$this->curl->get($uri, $getParams);
break;
case 'post':
$this->curl->post($uri . '?' . http_build_query($getParams), $postParams);
break;
case 'delete':
$this->curl->delete($uri, $getParams);
break;
case 'put':
$this->curl->put($uri . '?' . http_build_query($getParams), $postParams);
break;
default:
throw new \Exception('Requested method behaviour is not defined yet');
}
if ($this->curl->curl_error_code == 28) {
throw new \Exception('Connection timeout', 28);
}
$error = $this->curl->error;
if ($error) {
throw new \Exception($error . ' (HTTP CODE ' . $this->curl->http_status_code . ')');
}
// If JSONP is activated, return instantly
if (isset($extraParams['callback'])) {
return $this->curl->response;
}
// Otherwise decode and return
$result = json_decode($this->curl->response);
return $result;
}
示例4: delete_stream
public function delete_stream($delete_key)
{
$curl = new Curl();
$curl->setHeader('Phant-Delete-Key', $delete_key);
$curl->delete($this->server_hostname . '/streams/' . $this->public_key);
if ($curl->error)
{
return array(
'http_status' => $curl->response_headers['Status-Line']
);
}
else
{
return array(
'http_status' => $curl->response_headers['Status-Line']
);
}
}
示例5: testSetUrl
public function testSetUrl()
{
$data = array('key' => 'value');
$curl = new Curl();
$curl->setHeader('X-DEBUG-TEST', 'get');
$curl->setUrl(Test::TEST_URL);
$curl->delete($data);
$this->assertEquals(Test::TEST_URL, $curl->base_url);
$this->assertEquals('key=value', $curl->response);
$curl = new Curl();
$curl->setHeader('X-DEBUG-TEST', 'get');
$curl->setUrl(Test::TEST_URL);
$curl->get($data);
$this->assertEquals(Test::TEST_URL, $curl->base_url);
$this->assertEquals('key=value', $curl->response);
$curl = new Curl();
$curl->setHeader('X-DEBUG-TEST', 'get');
$curl->setUrl(Test::TEST_URL);
$curl->head($data);
$this->assertEquals(Test::TEST_URL, $curl->base_url);
$this->assertEquals('HEAD /?key=value HTTP/1.1', $curl->request_headers['Request-Line']);
$curl = new Curl();
$curl->setHeader('X-DEBUG-TEST', 'get');
$curl->setUrl(Test::TEST_URL);
$curl->options($data);
$this->assertEquals(Test::TEST_URL, $curl->base_url);
$this->assertEquals('key=value', $curl->response);
$curl = new Curl();
$curl->setHeader('X-DEBUG-TEST', 'request_method');
$curl->setUrl(Test::TEST_URL);
$curl->patch($data);
$this->assertEquals(Test::TEST_URL, $curl->base_url);
$this->assertEquals('PATCH', $curl->response);
$curl = new Curl();
$curl->setHeader('X-DEBUG-TEST', 'post');
$curl->setUrl(Test::TEST_URL);
$curl->post($data);
$this->assertEquals(Test::TEST_URL, $curl->base_url);
$this->assertEquals('key=value', $curl->response);
$curl = new Curl();
$curl->setHeader('X-DEBUG-TEST', 'put');
$curl->setUrl(Test::TEST_URL);
$curl->put($data);
$this->assertEquals(Test::TEST_URL, $curl->base_url);
$this->assertEquals('key=value', $curl->response);
}
示例6: Curl
<?php
require __DIR__ . '/vendor/autoload.php';
use Curl\Curl;
// curl --request DELETE "https://httpbin.org/delete?key=value" --data "a=1&b=2&c=3"
$curl = new Curl();
$curl->delete('https://httpbin.org/delete', array('key' => 'value'), array('a' => '1', 'b' => '2', 'c' => '3'));
if ($curl->error) {
echo 'Error: ' . $curl->errorCode . ': ' . $curl->errorMessage . "\n";
} else {
echo 'Data server received via DELETE:' . "\n";
var_dump($curl->response->form);
}
示例7: contact
/**
* 向環信請求
* @param $url
* @param string $params
* @param string $type POST|GET
* @return mixed
* @throws \ErrorException
*/
private function contact($url, $params = '', $type = 'POST')
{
$postData = '';
if (is_array($params)) {
$postData = json_encode($params);
}
$curl = new Curl();
$curl->setUserAgent('Jasonwx/Easemob SDK; Jason Wang<jasonwx@163.com>');
$curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
$curl->setOpt(CURLOPT_SSL_VERIFYHOST, false);
$curl->setHeader('Content-Type', 'application/json');
$token = "";
if ($url !== $this->url . '/token') {
$token = $this->getToken();
$curl->setHeader('Authorization', 'Bearer ' . $token);
}
switch ($type) {
case 'POST':
$curl->post($url, $postData);
break;
case 'GET':
$curl->get($url);
break;
case 'DELETE':
$curl->delete($url);
break;
}
$curl->close();
if ($this->debug) {
echo "URL: {$url}\n Header: {$token} \nBody: \"{$postData}\"\n";
}
if ($curl->error) {
throw new \ErrorException('CURL Error: ' . $curl->error_message, $curl->error_code);
}
if ($this->debug) {
// echo "return: {$curl->raw_response} \n";
}
return json_decode($curl->raw_response, true);
}
示例8: testSetUrl
public function testSetUrl()
{
$data = array('key' => 'value');
$curl = new Curl();
$curl->setUrl(Test::TEST_URL);
$curl->delete($data);
$this->assertEquals('DELETE /?key=value HTTP/1.1', $curl->requestHeaders['Request-Line']);
$this->assertEquals(Test::TEST_URL . '?key=value', $curl->effectiveUrl);
$curl = new Curl();
$curl->setUrl(Test::TEST_URL);
$curl->get($data);
$this->assertEquals('GET /?key=value HTTP/1.1', $curl->requestHeaders['Request-Line']);
$this->assertEquals(Test::TEST_URL . '?key=value', $curl->effectiveUrl);
$curl = new Curl();
$curl->setUrl(Test::TEST_URL);
$curl->head($data);
$this->assertEquals('HEAD /?key=value HTTP/1.1', $curl->requestHeaders['Request-Line']);
$this->assertEquals(Test::TEST_URL . '?key=value', $curl->effectiveUrl);
$curl = new Curl();
$curl->setUrl(Test::TEST_URL);
$curl->options($data);
$this->assertEquals('OPTIONS /?key=value HTTP/1.1', $curl->requestHeaders['Request-Line']);
$this->assertEquals(Test::TEST_URL . '?key=value', $curl->effectiveUrl);
$curl = new Curl();
$curl->setUrl(Test::TEST_URL);
$curl->patch($data);
$this->assertEquals('PATCH / HTTP/1.1', $curl->requestHeaders['Request-Line']);
$this->assertEquals(Test::TEST_URL, $curl->effectiveUrl);
$curl = new Curl();
$curl->setUrl(Test::TEST_URL);
$curl->post($data);
$this->assertEquals('POST / HTTP/1.1', $curl->requestHeaders['Request-Line']);
$this->assertEquals(Test::TEST_URL, $curl->effectiveUrl);
$curl = new Curl();
$curl->setUrl(Test::TEST_URL);
$curl->put($data);
$this->assertEquals('PUT / HTTP/1.1', $curl->requestHeaders['Request-Line']);
$this->assertEquals(Test::TEST_URL, $curl->effectiveUrl);
}