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


PHP Request::delete方法代码示例

本文整理汇总了PHP中Httpful\Request::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::delete方法的具体用法?PHP Request::delete怎么用?PHP Request::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Httpful\Request的用法示例。


在下文中一共展示了Request::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: DELETE

 /**
  * PUT command
  * @return bool true if ok
  */
 public function DELETE($url)
 {
     try {
         $this->response = Request::delete($url)->authenticateWith($this->username, $this->password)->expectsType('xml')->send();
     } catch (Exception $ex) {
         \Yii::error($exc->getMessage() . "\n" . $exc->getTraceAsString());
         return false;
     }
     if ($this->isOk()) {
         return true;
     }
     return false;
 }
开发者ID:jarekkozak,项目名称:yii2-libs,代码行数:17,代码来源:KieClient.php

示例2: RestClient

 /**
  * Interface for performing requests to PromisePay endpoints
  *
  * @param string $method required One of the four supported requests methods (get, post, delete, patch)
  * @param string $entity required Endpoint name
  * @param string $payload optional URL encoded data query
  * @param string $mime optional Set specific MIME type. Supported list can be seen here: http://phphttpclient.com/docs/class-Httpful.Mime.html
  */
 public static function RestClient($method, $entity, $payload = null, $mime = null)
 {
     // Check whether critical constants are defined.
     if (!defined(__NAMESPACE__ . '\\API_URL')) {
         die("Fatal error: API_URL constant missing. Check if environment has been set.");
     }
     if (!defined(__NAMESPACE__ . '\\API_LOGIN')) {
         die("Fatal error: API_LOGIN constant missing.");
     }
     if (!defined(__NAMESPACE__ . '\\API_PASSWORD')) {
         die("Fatal error: API_PASSWORD constant missing.");
     }
     if (!is_null($payload)) {
         if (is_array($payload) || is_object($payload)) {
             $payload = http_build_query($payload);
         }
         // if the payload isn't array or object, leave it intact
     }
     $url = constant(__NAMESPACE__ . '\\API_URL') . $entity . '?' . $payload;
     switch ($method) {
         case 'get':
             $response = Request::get($url)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         case 'post':
             $response = Request::post($url)->body($payload, $mime)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         case 'delete':
             $response = Request::delete($url)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         case 'patch':
             $response = Request::patch($url)->body($payload, $mime)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         default:
             throw new Exception\ApiUnsupportedRequestMethod("Unsupported request method {$method}.");
     }
     // check for errors
     if ($response->hasErrors()) {
         $errors = static::buildErrorMessage($response);
         switch ($response->code) {
             case 401:
                 throw new Exception\Unauthorized($errors);
                 break;
             case 404:
                 throw new Exception\NotFound($errors);
             default:
                 throw new Exception\Api($errors);
                 break;
         }
     }
     return $response;
 }
开发者ID:kublermdk,项目名称:promisepay-php,代码行数:59,代码来源:PromisePay.php

示例3: getHttpServer

 /**
  * @param Request $request
  *
  * @return HttpServer
  */
 public function getHttpServer(Request $request)
 {
     $url = $request->getUri();
     switch ($request->getMethod()) {
         case Request::METHOD_POST:
             $httpServer = HttpServer::post($url);
             break;
         case Request::METHOD_PUT:
             $httpServer = HttpServer::put($url);
             break;
         case Request::METHOD_DELETE:
             $httpServer = HttpServer::delete($url);
             break;
         default:
             $httpServer = HttpServer::get($url);
             break;
     }
     if ($request->headers) {
         $httpServer->addHeaders($request->headers->all());
     }
     if ($request->getUser()) {
         $httpServer->authenticateWith($request->getUser(), $request->getPassword());
     }
     if ($request->getContent()) {
         $httpServer->body($request->getContent());
     }
     return $httpServer;
 }
开发者ID:dongww,项目名称:web-monitor,代码行数:33,代码来源:Http.php

示例4: delete

 /**
  * {@inheritdoc}
  */
 public function delete($url, $content = '')
 {
     $response = Request::delete()->addHeader("Accept", "application/json")->addHeader('Content-type', "application/json")->addHeader("X-TOKEN", $this->api)->body($content)->send();
     if ($this->isResponseOk($response->code)) {
         return $response->body;
     }
 }
开发者ID:uaktags,项目名称:ngcsWP,代码行数:10,代码来源:HttpAdapter.php

示例5: delete

 protected function delete($uri, array $params = null)
 {
     if (!is_null($params)) {
         $params = self::clean_array($params);
         return self::process_response(Request::delete(self::$base_uri . $uri . '?' . http_build_query($params))->send());
     }
     return self::process_response(Request::delete(self::$base_uri . $uri)->send());
 }
开发者ID:creazy412,项目名称:vmware-win10-c65-drupal7,代码行数:8,代码来源:Yotpo.php

示例6: delete

 public static function delete($url, $data = [], $auth = true)
 {
     $api = self::$api;
     $response = \Httpful\Request::delete($api->url . $url);
     // Will parse based on Content-Type
     if ($auth) {
         $response->authenticateWith($api->username, $api->password);
     }
     $response = $response->sendsJson()->body(json_encode($data))->send();
     return (array) $response->body;
 }
开发者ID:paxpelus,项目名称:phalcon-web-rest-client,代码行数:11,代码来源:Apicalls.php

示例7: _DELETE

 public static function _DELETE($url)
 {
     $real_url = \Marketcloud\Marketcloud::$apiBaseUrl . $url;
     $response = \Httpful\Request::delete($real_url)->expectsJson()->addHeader('Authorization', \Marketcloud\Marketcloud::getAuthorizationHeader())->send();
     // We check the response code
     // If the code is 401, then the Token might be expired.
     // If it is the case, we re-authenticate the client using the stored credentials.
     //
     if ($response->code == 401) {
         // We have to re-authenticate
         $auth_response = \Marketcloud\Marketcloud::authenticate();
         return self::_DELETE($url);
     } else {
         return $response;
     }
 }
开发者ID:marketcloud,项目名称:marketcloud-php,代码行数:16,代码来源:ApiResource.php

示例8: CallAPI

 public static function CallAPI($method, $url, $data = false)
 {
     $response = null;
     switch ($method) {
         case "GET":
             $response = \Httpful\Request::get($url)->expects("json")->send();
             break;
         case "POST":
             $response = \Httpful\Request::post($url)->body($data)->sendsAndExpects("json")->send();
             break;
         case "PUT":
             $response = \Httpful\Request::put($url)->body($data)->sendsAndExpects("json")->send();
             break;
         case "DELETE":
             $response = \Httpful\Request::delete($url)->body($data)->sendsAndExpects("json")->send();
             break;
     }
     return is_null($response) ? null : $response->body;
 }
开发者ID:rayardinanda,项目名称:britecore,代码行数:19,代码来源:RestAPIHelper.class.php

示例9: RestClient

 public function RestClient($method, $entity, $payload = null, $mime = null)
 {
     $username = $this->Login();
     $password = $this->Password();
     $url = $this->BaseUrl() . $entity . "?" . $payload;
     switch ($method) {
         case 'get':
             $response = Request::get($url)->authenticateWith($username, $password)->send();
             return $response;
             break;
         case 'post':
             $response = Request::post($url)->body($payload, $mime)->authenticateWith($username, $password)->send();
             return $response;
             break;
         case 'delete':
             $response = Request::delete($url)->authenticateWith($username, $password)->send();
             return $response;
             break;
         case 'patch':
             $response = Request::patch($url)->body($payload, $mime)->authenticateWith($username, $password)->send();
             return $response;
             break;
     }
 }
开发者ID:gjorgic,项目名称:my-promisepay-php,代码行数:24,代码来源:ApiAbstract.php

示例10: processAction

 public function processAction(CRM_Civirules_TriggerData_TriggerData $triggerData)
 {
     //do the http post process
     $uri = $this->getFullUri($triggerData);
     $method = $this->getHttpMethod();
     $body = http_build_query($this->getBodyParams($triggerData));
     switch (strtolower($method)) {
         case 'post':
             $request = \Httpful\Request::post($uri, $body);
             break;
         case 'put':
             $request = \Httpful\Request::put($uri, $body);
             break;
         case 'delete':
             $request = \Httpful\Request::delete($uri);
             break;
         case 'head':
             $request = \Httpful\Request::head($uri);
             break;
         case 'patch':
             $request = \Httpful\Request::patch($uri, $body);
             break;
         case 'options':
             $request = \Httpful\Request::options($uri, $body);
             break;
         case 'get':
             $request = $response = \Httpful\Request::get($uri);
             break;
         default:
             throw new Exception('Invalid HTTP Method');
     }
     $request->neverSerializePayload();
     $request = $this->alterHttpRequestObject($request, $triggerData);
     $response = $request->send();
     $this->handleResponse($response, $request, $triggerData);
 }
开发者ID:CiviCooP,项目名称:org.civicoop.civiruleshttppost,代码行数:36,代码来源:HttpPostAction.php

示例11: request

 public function request($url, $data, $header, $method = 'POST')
 {
     $logger = JPushLog::getLogger();
     $logger->debug("Send " . $method, array("method" => $method, "uri" => $url, "headers" => $header, "body" => $data));
     $request = null;
     if ($method === 'POST') {
         $request = Request::post($url);
     } else {
         if ($method == 'DELETE') {
             $request = Request::delete($url);
         } else {
             $request = Request::get($url);
         }
     }
     if (!is_null($data)) {
         $request->body($data);
     }
     $request->addHeaders($header)->authenticateWith($this->appKey, $this->masterSecret)->timeout(self::READ_TIMEOUT);
     $response = null;
     for ($retryTimes = 0;; $retryTimes++) {
         try {
             $response = $request->send();
             break;
         } catch (ConnectionErrorException $e) {
             if (strpos($e->getMessage(), '28')) {
                 throw new APIConnectionException("Response timeout. Your request has probably be received by JPush Server,please check that whether need to be pushed again.", true);
             }
             if (strpos($e->getMessage(), '56')) {
                 // resolve error[56 Problem (2) in the Chunked-Encoded data]
                 throw new APIConnectionException("Response timeout, maybe cause by old CURL version. Your request has probably be received by JPush Server, please check that whether need to be pushed again.", true);
             }
             if ($retryTimes >= $this->retryTimes) {
                 throw new APIConnectionException("Connect timeout. Please retry later.");
             } else {
                 $logger->debug("Exception - Message:" . $e->getMessage() . ", Code:" . $e->getCode());
                 $logger->debug("Retry again send " . $method, array("method" => $method, "uri" => $url, "headers" => $header, "body" => $data, "retryTimes" => $retryTimes + 1));
             }
         }
     }
     return $response;
 }
开发者ID:noikiy,项目名称:jpush-api-php-client,代码行数:41,代码来源:JPushClient.php

示例12: delete

 public function delete(Entity $instance)
 {
     if (!$instance->isAllowedMethod(__FUNCTION__)) {
         throw new \DomainException(__FUNCTION__ . ' not allowed on this entity.');
     }
     $url = sprintf('%s/%s/%s/%s', $this->getApiUrl(), $this->getNetworkId(), $this->getEndpointName($instance), $instance->getId());
     $response = \Httpful\Request::delete($url)->authenticateWith($this->getLogin(), $this->getPassword())->send();
     if ($response->hasErrors()) {
         $exception = json_decode($response->raw_body);
         throw new \UnexpectedValueException(sprintf("API response raised a '%s' exception with a message: '%s'. Status code %s", $exception->name, $exception->message, $response->code));
     }
     return $instance;
 }
开发者ID:2y-media,项目名称:smartadserver-api,代码行数:13,代码来源:Client.php

示例13: delete

 public function delete($endpoint, $options = [])
 {
     $uri = Client::endpoint() . $endpoint . Client::getUriOptions($options);
     $response = \Httpful\Request::delete($uri)->authenticateWith(Client::key(), Client::secret())->addHeaders(Client::headers())->send();
     return $response;
 }
开发者ID:vicioux,项目名称:apisdk,代码行数:6,代码来源:client.php

示例14: array

echo "response http status: " . $response->code . "\n\n";
echo "Teilinhalt der response: " . $response->body->createdPersonWithName . "\n\n";
// var_dump($response);
// ------------- der anfang des var_dump - outputs hier: ---------------------
// ["body"]=>
// object(stdClass)#14 (2) {
// ["func"]=>
// string(6) "create"
// ["createdPersonWithName"]=>
// string(4) "emma"
// }
// ["raw_body"]=>
// string(48) "{"func":"create","createdPersonWithName":"emma"}"
// ===================================================================
// PUT Request  (update single person)
// ===================================================================
$uri = "http://localhost/testapp/index.php/api/persons/emma";
$payload = array('attributeToBeUPdated' => 'newValue');
echo "\n\n================ PUT:  {$uri} \n";
$response = \Httpful\Request::put($uri)->sendsJson()->body($payload)->send();
// and finally, fire that thing off!
# var_dump($response);
echo "response http status: " . $response->code . "\n\n";
echo "Teilinhalt der response: " . $response->body->updatedPersonWithId . "\n\n";
// ===================================================================
// DELETE Request  (delete single person)
// ===================================================================
$uri = "http://localhost/testapp/index.php/api/persons/todelete";
echo "\n\n================ DELETE:  {$uri} \n";
$response = \Httpful\Request::delete($uri)->send();
echo "response http status: " . $response->code . "\n\n";
开发者ID:emm44,项目名称:myfirst,代码行数:31,代码来源:phprestclient.php

示例15: deleteProjectRun

 /**
  * Delete a project run. This cancels a run if running, and deletes the run
  * and its data.
  * @param  string $run_token run token of a project run.
  * @return string            json response with run token that run was
  *                                deleted.
  */
 public function deleteProjectRun($run_token)
 {
     $url = $this->getProjectRunDeleteApiUrl($run_token);
     $api_key = self::$config['api_key'];
     $response = PHPHttpful::delete($url)->send();
     if ($this->isResponseValid($response)) {
         self::$logger->info("Project run deleted successfully on parsehub of run_token {$run_token}");
         $data = $response->body;
         return $data;
     }
 }
开发者ID:msankhala,项目名称:parsehub-php,代码行数:18,代码来源:Parsehub.php


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