Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/GetResponseAPI3.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public function getForms($params = array())
* @return mixed
* @throws Exception
*/
private function call($api_method = null, $http_method = 'GET', $params = array())
private function call($api_method = null, $http_method = 'GET', $params = array(), $access_token = true)
{
if (empty($api_method)) {
return (object)array(
Expand All @@ -349,7 +349,18 @@ private function call($api_method = null, $http_method = 'GET', $params = array(

$params = json_encode($params);
$url = $this->api_url . '/' . $api_method;

if ($access_token === true) {
$options = array(
CURLOPT_URL => $url,
CURLOPT_ENCODING => 'gzip,deflate',
CURLOPT_FRESH_CONNECT => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_TIMEOUT => $this->timeout,
CURLOPT_HEADER => false,
CURLOPT_USERAGENT => 'PHP GetResponse client 0.0.2',
CURLOPT_HTTPHEADER => array('Authorization: Bearer ' . $this->api_key, 'Content-Type: application/json')
);
} else {
$options = array(
CURLOPT_URL => $url,
CURLOPT_ENCODING => 'gzip,deflate',
Expand All @@ -360,6 +371,7 @@ private function call($api_method = null, $http_method = 'GET', $params = array(
CURLOPT_USERAGENT => 'PHP GetResponse client 0.0.2',
CURLOPT_HTTPHEADER => array('X-Auth-Token: api-key ' . $this->api_key, 'Content-Type: application/json')
);
}

if (!empty($this->enterprise_domain)) {
$options[CURLOPT_HTTPHEADER][] = 'X-Domain: ' . $this->enterprise_domain;
Expand Down Expand Up @@ -403,4 +415,4 @@ private function setParams($params = array())
return http_build_query($result);
}

}
}