本文整理汇总了PHP中Requests::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Requests::delete方法的具体用法?PHP Requests::delete怎么用?PHP Requests::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Requests
的用法示例。
在下文中一共展示了Requests::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doDelete
function doDelete($url)
{
$response = Requests::delete($this->apiUrl . $url, $this->header);
return json_decode($response->body);
}
示例2: request
public function request($method, $url, $api_key, $data = NULL, $headers = array("Content-Type" => "application/json", "Accept" => "application/json"))
{
try {
$options = array('auth' => new \Requests_Auth_Basic(array($api_key, '')));
if ($method == "GET") {
$url_params = is_array($data) ? '?' . http_build_query($data) : '';
$response = \Requests::get(Client::BASE_URL . $url . $url_params, $headers, $options);
} else {
if ($method == "POST") {
$response = \Requests::post(Client::BASE_URL . $url, $headers, json_encode($data), $options);
} else {
if ($method == "PATCH") {
$response = \Requests::patch(Client::BASE_URL . $url, $headers, json_encode($data), $options);
} else {
if ($method == "DELETE") {
$response = \Requests::delete(Client::BASE_URL . $url, $headers, $options);
}
}
}
}
} catch (\Exception $e) {
throw new UnableToConnect();
}
if ($response->status_code >= 200 && $response->status_code <= 206) {
if ($method == "DELETE") {
return $response->status_code == 204 || $response->status_code == 200;
}
return json_decode($response->body);
}
if ($response->status_code == 400) {
$code = 0;
$message = "";
try {
$error = (array) json_decode($response->body)->errors[0];
$code = key($error);
$message = current($error);
} catch (\Exception $e) {
throw new UnhandledError($response->body, $response->status_code);
}
throw new InputValidationError($message, $code);
}
if ($response->status_code == 401) {
throw new AuthenticationError();
}
if ($response->status_code == 404) {
throw new NotFound();
}
if ($response->status_code == 403) {
throw new InvalidApiKey();
}
if ($response->status_code == 405) {
throw new MethodNotAllowed();
}
throw new UnhandledError($response->body, $response->status_code);
}
示例3: issue_request
function issue_request($render, $url, $headers, $body)
{
if ($render['METHOD'] == 'POST') {
return \Requests::post($url, $headers, $body);
} else {
if ($render['METHOD'] == 'PUT') {
return \Requests::put($url, $headers, $body);
} else {
if ($render['METHOD'] == 'DELETE') {
return \Requests::delete($url, $headers);
}
}
}
return \Requests::get($url, $headers);
}
示例4: request
public function request($method, $url, $api_key, $data = NULL, $headers = array("Content-Type" => "application/json", "Accept" => "application/json"))
{
try {
$options = array('auth' => new AuthBearer($api_key), 'timeout' => 120);
if ($method == "GET") {
$url_params = is_array($data) ? '?' . http_build_query($data) : '';
$response = \Requests::get(Culqi::$api_base . $url . $url_params, $headers, $options);
} else {
if ($method == "POST") {
$response = \Requests::post(Culqi::$api_base . $url, $headers, json_encode($data), $options);
} else {
if ($method == "PATCH") {
$response = \Requests::patch(Culqi::$api_base . $url, $headers, json_encode($data), $options);
} else {
if ($method == "DELETE") {
$response = \Requests::delete(Culqi::$api_base, $options);
}
}
}
}
} catch (\Exception $e) {
throw new Errors\UnableToConnect();
}
if ($response->status_code >= 200 && $response->status_code <= 206) {
if ($method == "DELETE") {
return $response->status_code == 204 || $response->status_code == 200;
}
return json_decode($response->body);
}
if ($response->status_code == 400) {
$code = 0;
$message = "";
throw new Errors\UnhandledError($response->body, $response->status_code);
}
if ($response->status_code == 401) {
throw new Errors\AuthenticationError();
}
if ($response->status_code == 404) {
throw new Errors\NotFound();
}
if ($response->status_code == 403) {
throw new Errors\InvalidApiKey();
}
if ($response->status_code == 405) {
throw new Errors\MethodNotAllowed();
}
throw new Errors\UnhandledError($response->body, $response->status_code);
}
示例5: request
protected function request($method, $url, $client_id, $secret_id, $data = NULL, $headers = array("Content-Type" => "application/json", "Accept" => "application/json"))
{
try {
$options = array('auth' => new \Requests_Auth_Basic(array($client_id, $secret_id)));
if ($method == "GET") {
$url_params = is_array($data) ? '?' . http_build_query($data) : '';
$response = \Requests::get($this->base_url . $url . $url_params, $headers, $options);
} else {
if ($method == "POST") {
$response = \Requests::post($this->base_url . $url, $headers, json_encode($data), $options);
} else {
if ($method == "PATCH") {
$response = \Requests::patch($this->base_url . $url, $headers, json_encode($data), $options);
} else {
if ($method == "DELETE") {
$response = \Requests::delete($this->base_url . $url, $headers, $options);
}
}
}
}
} catch (\Exception $e) {
throw new \Exception(Error_Message::ERROR_CONNECTION);
}
if ($response->status_code >= 200 && $response->status_code <= 206) {
if ($method == "DELETE") {
return $response->status_code == 204 || $response->status_code == 200;
}
return json_decode($response->body);
}
if ($response->status_code >= 400 && $response->status_code <= 406) {
try {
$error = (array) json_decode($response->body);
$code = $error['errorCode'];
$message = $error['errorMessage'];
} catch (\Exception $e) {
throw new \Exception($response->body, $response->status_code);
}
throw new \Exception($message, $code);
}
throw new \Exception($response->body, $response->status_code);
}
示例6: testDELETE
public function testDELETE()
{
$request = Requests::delete(httpbin('/delete'), array(), $this->getOptions());
$this->assertEquals(200, $request->status_code);
$result = json_decode($request->body, true);
$this->assertEquals(httpbin('/delete'), $result['url']);
$this->assertEmpty($result['args']);
}
示例7: httpResponse
httpResponse($requests->getMyRequests());
break;
case validateRoute('POST', 'requests'):
$logs = new Logs($db, $user);
$requests = new Requests($db, $user, $logs);
httpResponse($requests->createOrUpdate($postdata));
break;
case validateRoute('PATCH', 'requests/\\d+'):
$requests = new Requests($db, $user);
httpResponse($requests->createOrUpdate($postdata, (int) $params[1]));
break;
case validateRoute('DELETE', 'requests/\\d+'):
$logs = new Logs($db, $user);
$mailbox = new Mailbox($db, $user);
$requests = new Requests($db, $user, $logs, $mailbox);
httpResponse($requests->delete($params[1], $_GET["reason"]));
break;
case validateRoute('POST', 'requests/\\d+/votes'):
$requests = new Requests($db, $user);
$response = $requests->vote($params[1], (int) $postdata["reward"]);
httpResponse($response);
break;
case validateRoute('GET', 'mailbox'):
$mailbox = new Mailbox($db, $user);
list($result, $totalCount) = $mailbox->query((int) $_GET["location"] ?: 0, (int) $_GET["limit"] ?: 10, (int) $_GET["index"] ?: 0);
httpResponse($result, $totalCount);
break;
case validateRoute('PATCH', 'mailbox/\\d+'):
$mailbox = new Mailbox($db, $user);
httpResponse($mailbox->update((int) $params[1], $postdata));
break;
示例8:
$tf->assertSame($req->body, 'PUT /on');
$req = Requests::get($url . '/multi');
$tf->assertSame($req->body, 'MULTI /multi');
$req = Requests::put($url . '/multi');
$tf->assertSame($req->body, 'MULTI /multi');
$req = Requests::post($url . '/multi');
$tf->assertSame($req->body, 'MULTI /multi');
$req = Requests::delete($url . '/multi');
$tf->assertNotSame($req->body, 'MULTI /multi');
$req = Requests::get($url . '/any');
$tf->assertSame($req->body, 'ANY /any');
$req = Requests::post($url . '/any');
$tf->assertSame($req->body, 'ANY /any');
$req = Requests::put($url . '/any');
$tf->assertSame($req->body, 'ANY /any');
$req = Requests::delete($url . '/any');
$tf->assertSame($req->body, 'ANY /any');
// $req = Requests::head($url . '/any');
// $tf->assertSame($req->body, 'ANY /any');
$req = Requests::get($url . '/space/');
$tf->assertSame($req->body, 'GET /space/');
$req = Requests::post($url . '/space/');
$tf->assertSame($req->body, 'POST /space/');
$req = Requests::get($url . '/_all');
$tf->assertSame($req->body, 'all');
$req = Requests::post($url . '/_all');
$tf->assertSame($req->body, 'all');
$req = Requests::post($url . '/lla');
$tf->assertSame($req->body, 'all');
$req = Requests::put($url . '/all');
$tf->assertSame($req->body, 'all');
示例9: deleteAPI
function deleteAPI($method, $function, $params = [], $keep = TRUE)
{
$params = is_array($params) ? $params : (array) $params;
$params = count($params) < 1 ? '' : '?' . http_build_query($params);
$headers = ['X-API-KEY' => APPLICATION_KEY, 'TOKEN' => $this->session->userdata('token')];
$response = Requests::delete(API_URL . $method . '/' . $function . $params, $headers);
$result = json_decode($response->body);
// UPDATE TOKEN TO SESSION
if (!empty($result->token)) {
if ((bool) $this->session->userdata('user_id')) {
$this->session->set_userdata('token', $result->token);
}
}
$output['execution_time_api'] = $result->execution_time;
$output['environment_api'] = $result->environment;
$output['message'] = $result->message;
// OUTPUT
if (!$keep) {
$this->xresponse($result->status, $output, $response->status_code);
} else {
return $result;
}
}
示例10: deleteItem
/**
* Delete an existing item (DELETE items/{id} request).
*
* @param stdClass $item_id ID of the item to be deleted.
* @throws Exception If an error response was returned by VWflow
*/
function deleteItem($item_id)
{
$url = $this->uri . "items/" . $item_id . "/";
$headers = array('Content-Type' => 'application/json');
$response = Requests::delete($url, $headers, $this->request_options);
$this->_checkErrorResponse($response);
}
示例11: _request
/**
* DSL wrapper to make a HTTP request based on supported HTTP methods.
*
* @param string $uri Path to API resource
* @param array $args Associative array of passed arguments
* @param array $headers List of passed headers
* @param string $method HTTP method
* @return array Processed response
* @see Sixreps::_response
*/
protected function _request($uri, $args = array(), $headers = array(), $method = 'GET')
{
$url = $this->_host . trim($uri, '/');
switch ($method) {
case 'GET':
if (!empty($args)) {
$url = $url . '?' . http_build_query($args);
}
$request = Requests::get($url, array());
break;
case 'POST':
$request = Requests::post($url, array(), $args);
break;
case 'PUT':
$request = Requests::put($url, array(), $args);
break;
case 'DELETE':
if (!empty($args)) {
$url = $url . '?' . http_build_query($args);
}
$request = Requests::delete($url, array());
break;
default:
throw new InvalidArgumentException(sprintf('Unsupported %s HTTP method. It should match one of %s keywords.', $method, implode(', ', $this->_http_methods)));
}
$body = $request->body;
$info['headers'] = $request->headers;
$info['headers'] = $request->headers;
$info['status_code'] = $request->status_code;
$info['success'] = $request->success;
$info['redirects'] = $request->redirects;
$info['url'] = $request->url;
return $this->_response($body, $info, $method);
}
示例12: clearDnsCache
/**
* Method for clearing the DNS cache set with remapHosts
*
* @return string
*/
public function clearDnsCache()
{
$url = "http://{$this->browsermob_url}/proxy/{$this->port}/dns/cache";
$response = Requests::delete($url);
return $response;
}
示例13: delete
/**
* Delete the object
*
* @throws Requests_Exception Failed to delete object
* @return boolean Was the deletion successful?
*/
public function delete($permanent = false)
{
$url = $this->meta['links']['self'];
if ($permanent) {
if (strpos($url, '?') !== false) {
$url .= '&force=true';
} else {
$url .= '?force=true';
}
}
$response = Requests::delete($url, array(), $this->api->getDefaultOptions());
$response->throw_for_status();
$this->data = array();
$this->changed = array();
return true;
}
示例14: file_get_contents
<?php
include 'baseline.php';
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$newsletter_delete = $config['BASEURL'] . '/users/' . $request->ekstern_id . '/nyhedsbreve/' . $config['TBT_NID'] . '?location_id=' . $config['LOCATION_ID'];
$response = Requests::delete($newsletter_delete, $headers, null);
echo $response->body;
示例15: array
<?php
include 'baseline.php';
$url = $config['BASEURL'] . '/users/' . $request->ekstern_id . '/nyhedsbreve/' . $config['GODTTIP_NID'] . '?location_id=' . $config['LOCATION_ID'];
$headers = array('Content-Type' => 'application/json');
$response = Requests::delete($url);
echo $response->body;