public function checkConnection()
{
//If not login properly the construct launch an exception
$connection = true;
try {
$user = $this->_credentials['user'];
$password = $this->_credentials['password'];
$url = "https://services.daisycon.com:443/publishers?page=1&per_page=100";
// initialize curl resource
$ch = \curl_init();
// set the http request authentication headers
$headers = array('Authorization: Basic ' . \base64_encode($user . ':' . $password));
// set curl options
\curl_setopt($ch, CURLOPT_URL, $url);
\curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// execute curl
$response = \curl_exec($ch);
$publisherList = \json_decode($response, true);
foreach ($publisherList as $publisher) {
$this->_publisherId[] = $publisher["id"];
}
if (\count($this->_publisherId) == 0) {
throw new \Exception("No publisher found");
}
} catch (\Exception $e) {
$connection = false;
}
return $connection;
}