当前位置: 首页>>代码示例>>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;未经允许,请勿转载。