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


PHP Requests::delete方法代码示例

本文整理汇总了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);
 }
开发者ID:replay42,项目名称:JodelPHP,代码行数:5,代码来源:jodel.class.php

示例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);
 }
开发者ID:mango,项目名称:mango-php,代码行数:55,代码来源:client.php

示例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);
}
开发者ID:coviu,项目名称:coviu-video-calls,代码行数:15,代码来源:Request.php

示例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);
 }
开发者ID:culqi,项目名称:culqi-php,代码行数:48,代码来源:Client.php

示例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);
 }
开发者ID:pagomio,项目名称:pagomio-sdk-php,代码行数:41,代码来源:client.php

示例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']);
 }
开发者ID:majinhui04,项目名称:pretty,代码行数:8,代码来源:Base.php

示例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;
开发者ID:lordgabber,项目名称:rartracker,代码行数:31,代码来源:api-v1.php

示例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');
开发者ID:bafs,项目名称:via,代码行数:31,代码来源:methodsTest.php

示例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;
     }
 }
开发者ID:antho-firuze,项目名称:_g.ene.sys_remake_,代码行数:23,代码来源:Getme.php

示例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);
 }
开发者ID:vwflow,项目名称:vwflow-php,代码行数:13,代码来源:VWflow.php

示例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);
 }
开发者ID:rizarsyi,项目名称:sixreps-php-sdk,代码行数:44,代码来源:Sixreps.php

示例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;
 }
开发者ID:jjanvier,项目名称:PHPBrowserMobProxy,代码行数:11,代码来源:Client.php

示例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;
 }
开发者ID:NikDevPHP,项目名称:client-php,代码行数:22,代码来源:Object.php

示例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;
开发者ID:BerlingskeMedia,项目名称:thebusinesstarget,代码行数:8,代码来源:unsubscribe.php

示例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;
开发者ID:BerlingskeMedia,项目名称:godttip,代码行数:7,代码来源:unsubscribe.php


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