delete() public static method

Send DELETE request to a URL
public static delete ( string $url, array $headers = [], mixed $body = null, string $username = null, string $password = null ) : unirest\Response
$url string URL to send the DELETE request to
$headers array additional headers to send
$body mixed DELETE body data
$username string Basic Authentication username (deprecated)
$password string Basic Authentication password (deprecated)
return unirest\Response
コード例 #1
0
ファイル: Texts.php プロジェクト: radiegtya/rapid-api-php
 public static function deleteAll($headers = null)
 {
     if (!$headers) {
         $headers = Rapid::getAuthHeader();
     }
     $response = Request::delete(Rapid::getUrl(self::$route), $headers);
     return Response::make($response);
 }
コード例 #2
0
ファイル: Ossbss.php プロジェクト: cloudapidev/apibay
 public function deleteInfo($url, $inputs = null, $param = null)
 {
     $url = setApiUrl($url, $param);
     //Log::info($url);
     $response = Unirest\Request::delete($url, $this->_headers, json_encode($inputs));
     //Log::info(json_encode($response));
     return dealResponse($response);
 }
コード例 #3
0
 /**
  * Delete an address from your account
  * @param  int        $addressId        Required parameter: The identifier of the address
  * @return mixed response from the API call*/
 public function deleteAddress($addressId)
 {
     //the base uri for api requests
     $queryBuilder = Configuration::BASEURI;
     $queryBuilder = Config::get('voxbone.base_uri');
     //prepare query string for API call
     $queryBuilder = $queryBuilder . '/regulation/address/{addressId}';
     //process optional query parameters
     APIHelper::appendUrlWithTemplateParameters($queryBuilder, array('addressId' => $addressId));
     //validate and preprocess url
     $queryUrl = APIHelper::cleanUrl($queryBuilder);
     //prepare headers
     $headers = array('User-Agent' => 'APIMATIC 2.0', 'Accept' => 'application/json', 'Content-type' => 'application/json; charset=utf-8');
     //prepare API request
     $response = Request::delete($queryUrl, $headers);
     //and invoke the API call request to fetch the response
     //$response = Unirest::getResponse($request);
     //Error handling using HTTP status codes
     if ($response->code < 200 || $response->code > 206) {
         //[200,206] = HTTP OK
         return $response;
     }
     return $response->body;
 }
コード例 #4
0
ファイル: Numberapi.php プロジェクト: cloudapidev/apibay
 public function deleteInfo($doUrl, $inputs, $number = null)
 {
     $url = setApiUrl($doUrl, $number);
     $response = Unirest\Request::delete($url, $this->_headers, json_encode($inputs));
     if ($response->code == 200) {
         // 			return $response->body;
         return 1;
     }
     return 0;
 }
コード例 #5
0
ファイル: routes.php プロジェクト: CamTosh/PufferPanel
 // Start Transaction so if the daemon errors we can rollback changes
 ORM::get_db()->beginTransaction();
 $node = ORM::forTable('nodes')->findOne($core->server->getData('node'));
 $ports = json_decode($node->ports, true);
 $ips = json_decode($node->ips, true);
 $ports[$core->server->getData('server_ip')][$core->server->getData('server_port')]++;
 $ips[$core->server->getData('server_ip')]['ports_free']++;
 $node->ips = json_encode($ips);
 $node->ports = json_encode($ports);
 $node->save();
 ORM::forTable('subusers')->where('server', $core->server->getData('id'))->deleteMany();
 ORM::forTable('permissions')->where('server', $core->server->getData('id'))->deleteMany();
 ORM::forTable('downloads')->where('server', $core->server->getData('id'))->deleteMany();
 ORM::forTable('servers')->where('id', $core->server->getData('id'))->deleteMany();
 try {
     $unirest = Request::delete("https://" . $core->server->nodeData('fqdn') . ":" . $core->server->nodeData('daemon_listen') . "/server", array('X-Access-Token' => $core->server->nodeData('daemon_secret'), 'X-Access-Server' => $core->server->getData('hash')));
     if ($unirest->code !== 204) {
         throw new Exception('<div class="alert alert-danger">Scales returned an error when trying to process your request. Scales said: ' . $unirest->raw_body . ' [HTTP/1.1 ' . $unirest->code . ']</div>');
     }
     ORM::get_db()->commit();
     $service->flash('<div class="alert alert-success">The requested server has been deleted from PufferPanel.</div>');
     $response->redirect('/admin/server')->send();
 } catch (Exception $e) {
     Debugger::log($e);
     if ($request->param('force') && $request->param('force') === "force") {
         ORM::get_db()->commit();
         $service->flash('<div class="alert alert-danger">An error was encountered with the daemon while trying to delete this server from the system. <strong>Because you requested a force delete this server has been removed from the panel regardless of the reason for the error. This server and its data may still exist on the Scales instance.</strong></div>');
         $response->redirect('/admin/server')->send();
         return;
     }
     ORM::get_db()->rollBack();
コード例 #6
0
 /**
  * Delete a specific contact list
  * @param  int     $listId      Required parameter: Example: 
  * @return string response from the API call*/
 public function deleteContactList($listId)
 {
     //check that all required arguments are provided
     if (!isset($listId)) {
         throw new \InvalidArgumentException("One or more required arguments were NULL.");
     }
     //the base uri for api requests
     $_queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $_queryBuilder = $_queryBuilder . '/lists/{list_id}';
     //process optional query parameters
     APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array('list_id' => $listId));
     //validate and preprocess url
     $_queryUrl = APIHelper::cleanUrl($_queryBuilder);
     //prepare headers
     $_headers = array('user-agent' => 'ClickSendSDK');
     //set HTTP basic auth parameters
     Request::auth(Configuration::$username, Configuration::$key);
     //and invoke the API call request to fetch the response
     $response = Request::delete($_queryUrl, $_headers);
     //Error handling using HTTP status codes
     if ($response->code == 400) {
         throw new APIException('BAD_REQUEST', 400, $response->body);
     } else {
         if ($response->code == 401) {
             throw new APIException('UNAUTHORIZED', 401, $response->body);
         } else {
             if ($response->code == 403) {
                 throw new APIException('FORBIDDEN', 403, $response->body);
             } else {
                 if ($response->code == 404) {
                     throw new APIException('NOT_FOUND', 404, $response->body);
                 } else {
                     if ($response->code == 405) {
                         throw new APIException('METHOD_NOT_FOUND', 405, $response->body);
                     } else {
                         if ($response->code == 429) {
                             throw new APIException('TOO_MANY_REQUESTS', 429, $response->body);
                         } else {
                             if ($response->code == 500) {
                                 throw new APIException('INTERNAL_SERVER_ERROR', 500, $response->body);
                             } else {
                                 if ($response->code < 200 || $response->code > 206) {
                                     //[200,206] = HTTP OK
                                     throw new APIException("HTTP Response Not OK", $response->code, $response->body);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $response->body;
 }
コード例 #7
0
ファイル: routes.php プロジェクト: PhenixH/PufferPanel
namespace PufferPanel\Core;

use Unirest;
$klein->respond('POST', '/node/ajax/files/[*]', function () use($core) {
    $core->routes = new Router\Router_Controller('Node\\Ajax\\Files', $core->server);
    $core->routes = $core->routes->loadClass();
});
$klein->respond('POST', '/node/ajax/files/delete', function ($request, $response) use($core) {
    if (!$core->permissions->has('files.delete')) {
        $response->code(403)->body("You are not authorized to perform this action.")->send();
        return;
    }
    $unirest = (object) array("code" => 500, "raw_body" => "Invalid function passed.");
    if ($request->param('deleteItemPath') && !empty($request->param('deleteItemPath'))) {
        try {
            $unirest = Unirest\Request::delete("https://" . $core->server->nodeData('fqdn') . ":" . $core->server->nodeData('daemon_listen') . "/server/file/" . rawurlencode($request->param('deleteItemPath')), array('X-Access-Token' => $core->server->getData('daemon_secret'), 'X-Access-Server' => $core->server->getData('hash')));
        } catch (\Exception $e) {
            \Tracy\Debugger::log($e);
            $response->code(500)->body("Unirest response error.")->send();
            return;
        }
    }
    if ($unirest->code !== 204) {
        $response->code($unirest->code)->body($unirest->raw_body)->send();
        return;
    }
    $response->code(200)->body("ok")->send();
});
$klein->respond('POST', '/node/ajax/files/compress', function ($request, $response) use($core) {
    if (!$core->permissions->has('files.zip')) {
        $response->code(403)->body("You are not authorized to perform this action.")->send();
コード例 #8
0
ファイル: Client.php プロジェクト: tubecode/tubecode
 public function delete($path, $parameter = [])
 {
     return Request::delete($this->base_uri . $path, [], $parameter);
 }
コード例 #9
0
 /**
  * @param string $uri
  * @param array $query
  *
  * @return Response
  */
 public function delete($uri, $query = [])
 {
     $headers = ['Accept' => 'application/json', 'X-IFSISTEM-TOKEN' => $this->token, 'X-IFSISTEM-DIL-ID' => $this->dilId];
     return Request::delete($this->uri . $uri, $headers, $query);
 }
コード例 #10
0
ファイル: RequestTest.php プロジェクト: RusinovIG/unirest-php
 public function testDelete()
 {
     $response = Request::delete('http://mockbin.com/request', array('Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded'), array('name' => 'Mark', 'nick' => 'thefosk'));
     $this->assertEquals(200, $response->code);
     $this->assertEquals('DELETE', $response->body->method);
 }
コード例 #11
0
ファイル: AbstractApi.php プロジェクト: ignittion/kong-php
 /**
  * The underlying call to the Kong Server
  *
  * @throws \Ignittion\Kong\KongException when something goes wrong with the Http request
  *
  * @param string $verb
  * @param string $uri
  * @param array $options
  * @param array $body
  * @return \stdClass
  */
 public function call($verb, $uri, array $params = [], array $body = [], array $headers = [])
 {
     $verb = strtoupper($verb);
     $api = "{$this->url}:{$this->port}/{$uri}";
     $headers = array_merge($headers, ['Content-Type: application/json']);
     try {
         switch ($verb) {
             case 'GET':
                 $request = RestClient::get($api, $headers, $params);
                 break;
             case 'POST':
                 $request = RestClient::post($api, $headers, $body);
                 break;
             case 'PUT':
                 $request = RestClient::put($api, $headers, $body);
                 break;
             case 'PATCH':
                 $request = RestClient::patch($api, $headers, $body);
                 break;
             case 'DELETE':
                 $request = RestClient::delete($api, $headers);
                 break;
             default:
                 throw new Exception('Unknown HTTP Request method.');
         }
     } catch (Exception $e) {
         throw new KongException($e->getMessage());
     }
     // save this request
     $this->body = $request->body;
     $this->headers = $request->headers;
     $this->httpCode = $request->code;
     $this->rawBody = $request->raw_body;
     // return a more simplified response
     $object = new stdClass();
     $object->code = $this->httpCode;
     $object->data = $this->body;
     return $object;
 }
コード例 #12
0
ファイル: Api.php プロジェクト: romka-chev/php-yandex-fotki
 /**
  * Удаление фотографии.
  *
  * <h1>Примеры</h1>
  *
  * <h2>Удаление альбома</h2>
  * <code>
  * <?php
  * $api->deletePhoto(12345678);
  * ?>
  * </code>
  *
  * @param int $photoId Id фотографии, которую нужно удалить
  *
  * @return $this
  * @throws \Yandex\Fotki\Exception\Api\Photo
  */
 public function deletePhoto($photoId)
 {
     $apiUrl = sprintf("http://api-fotki.yandex.ru/api/users/%s/photo/%s/", $this->_login, intval($photoId));
     $oAuthToken = $this->_transport->getOAuthToken();
     $fimpToken = $this->_transport->getFimpToken();
     $response = Request::delete($apiUrl, array('Authorization' => $oAuthToken ? "OAuth {$oAuthToken}" : "FimpToken realm=\"fotki.yandex.ru\", token=\"{$fimpToken}\""));
     if ($response->code === 204) {
         return $this;
     } else {
         throw new \Yandex\Fotki\Exception\Api\Photo($response->body, $response->code);
     }
 }