diff --git a/composer.json b/composer.json index 3bd66e2..6bdd7da 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,8 @@ { - "name": "getresponse/getresponse", + "name": "funnyfox777/getresponse-api-php", "description": "GetResponse API v3 client library.", - "version": "0.0.2", - "homepage": "https://github.com/GetResponse/getresponse-api-php", + "version": "1.0.5", + "homepage": "https://github.com/funnyfox777/getresponse-api-php", "keywords": ["GetResponse", "api", "email"], "type": "library", "license": "MIT", @@ -23,4 +23,4 @@ "autoload": { "files": ["src/GetResponseAPI3.class.php"] } -} \ No newline at end of file +} diff --git a/src/GetResponseAPI3.class.php b/src/GetResponseAPI3.class.php index 2782e2f..bec0ba5 100644 --- a/src/GetResponseAPI3.class.php +++ b/src/GetResponseAPI3.class.php @@ -14,6 +14,7 @@ class GetResponse private $api_key; private $api_url = 'https://api.getresponse.com/v3'; + private $api_url_enterprise = 'https://api3.getresponse360.pl/v3'; private $timeout = 8; public $http_status; @@ -34,13 +35,17 @@ class GetResponse * @param $api_key * @param null $api_url */ - public function __construct($api_key, $api_url = null) + public function __construct($api_key, $api_url = null, $enterprise_domain = null) { $this->api_key = $api_key; - + if (!empty($api_url)) { $this->api_url = $api_url; } + + if (!empty($enterprise_domain)) { + $this->enterprise_domain = $enterprise_domain; + } } /** @@ -348,7 +353,7 @@ private function call($api_method = null, $http_method = 'GET', $params = array( } $params = json_encode($params); - $url = $this->api_url . '/' . $api_method; + $url = ($this->enterprise_domain ? $this->api_url_enterprise : $this->api_url) . '/' . $api_method; $options = array( CURLOPT_URL => $url, @@ -363,6 +368,7 @@ private function call($api_method = null, $http_method = 'GET', $params = array( if (!empty($this->enterprise_domain)) { $options[CURLOPT_HTTPHEADER][] = 'X-Domain: ' . $this->enterprise_domain; + } if (!empty($this->app_id)) { @@ -403,4 +409,4 @@ private function setParams($params = array()) return http_build_query($result); } -} \ No newline at end of file +}