當前位置: 首頁>>代碼示例>>PHP>>正文


PHP HttpClient::response方法代碼示例

本文整理匯總了PHP中HttpClient::response方法的典型用法代碼示例。如果您正苦於以下問題:PHP HttpClient::response方法的具體用法?PHP HttpClient::response怎麽用?PHP HttpClient::response使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在HttpClient的用法示例。


在下文中一共展示了HttpClient::response方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: handleWebhook

 /**
  * Handles the actual webhook, happens in two steps:
  *
  * - Retrieves the $webhook_id and $event_id
  *
  * - Uses the key and secret provided to fetch the event object and casts it to an array
  *
  * - Calls the callable function with the Event object
  */
 private function handleWebhook()
 {
     $identifier = $this->field('identifier');
     if ($identifier !== $this->identifier) {
         return;
     }
     $event_id = $this->field('event_id');
     $webhook_id = $this->field('webhook_id');
     if (!$event_id || !$webhook_id) {
         Log::info($this->patrol, 'Webhook ' . $this->identifier . ' has no event_id or webhook_id');
         return;
     }
     $httpClient = new HttpClient($this->patrol, 'GET', 'webhooks/' . $webhook_id . '/events/' . $event_id);
     $response = $httpClient->response();
     if (!$response) {
         Log::info($this->patrol, 'Retrieving webhook from ' . $httpClient->getUrl() . ' failed');
         return;
     }
     $data = $this->field($response, 'data');
     if (!$data) {
         Log::info($this->patrol, 'Event has invalid format to be processed: ' . print_r($response, true));
     }
     $callable = $this->callback;
     if (is_callable($callable)) {
         $callable($data);
     }
 }
開發者ID:zdevil,項目名稱:patrolsdk-php,代碼行數:36,代碼來源:Webhook.php

示例2: _post

 /**
  * Perform a POST request based on this model
  *
  * @param string $url
  * @param array $data
  * @param string $class The class type where the result should be casted to
  *
  * @return PatrolSdk\Model
  */
 protected function _post($url, $data = [], $class = null)
 {
     $client = new HttpClient($this->patrol, 'post', $url, $data);
     $data = $client->response();
     if (isset($data['error'])) {
         $this->_error($data);
     }
     if (!isset($data['data'])) {
         return $data;
     }
     $data = $data['data'];
     $callee = $class ? $class : get_called_class();
     return Util::parseResponseToPatrolObject($this->patrol, $data, $callee, $this->defaults);
 }
開發者ID:zdevil,項目名稱:patrolsdk-php,代碼行數:23,代碼來源:PatrolModel.php


注:本文中的HttpClient::response方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。