From 370b5a0fd7c1dba60e3b973506ba087adba42be0 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 18 Apr 2015 18:44:45 -0400 Subject: Add Slack and Hipchat integrations for each projects --- app/Core/HttpClient.php | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'app/Core/HttpClient.php') diff --git a/app/Core/HttpClient.php b/app/Core/HttpClient.php index e1d90858..0803ec7a 100644 --- a/app/Core/HttpClient.php +++ b/app/Core/HttpClient.php @@ -2,6 +2,8 @@ namespace Core; +use Pimple\Container; + /** * HTTP client * @@ -31,16 +33,34 @@ class HttpClient */ const HTTP_USER_AGENT = 'Kanboard Webhook'; + /** + * Container instance + * + * @access protected + * @var \Pimple\Container + */ + protected $container; + + /** + * Constructor + * + * @access public + * @param \Pimple\Container $container + */ + public function __construct(Container $container) + { + $this->container = $container; + } + /** * Send a POST HTTP request * - * @static * @access public * @param string $url * @param array $data * @return string */ - public static function post($url, array $data) + public function post($url, array $data) { if (empty($url)) { return ''; @@ -63,6 +83,14 @@ class HttpClient ) )); - return @file_get_contents(trim($url), false, $context); + $response = @file_get_contents(trim($url), false, $context); + + if (DEBUG) { + $this->container['logger']->debug($url); + $this->container['logger']->debug(var_export($data, true)); + $this->container['logger']->debug($response); + } + + return $response; } } -- cgit v1.2.3