public function getMerchantList()
{
$merchants = array();
$user = $this->_credentials['user'];
$password = $this->_credentials['password'];
foreach ($this->_publisherId as $publisherId) {
$page = 1;
$pageSize = 100;
$finish = false;
while (!$finish) {
$url = "https://services.daisycon.com:443/publishers/{$publisherId}/programs?page={$page}&per_page={$pageSize}";
// 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);
$merchantList = \json_decode($response, true);
foreach ($merchantList as $merchant) {
if ($merchant['status'] == 'active') {
$obj = array();
$obj['cid'] = $merchant['id'];
$obj['name'] = $merchant['name'];
$merchants[] = $obj;
}
}
if (\count($merchantList) != $pageSize) {
$finish = true;
}
$page++;
}
}
return $merchants;
}