public function __construct($ak = null, $sk = null, $hostname = null)
{
//valid ak & sk
if (!$ak && !defined('BCS_AK') && false === getenv('HTTP_BAE_ENV_AK')) {
throw new BCS_Exception('No account key was passed into the constructor.');
}
if (!$sk && !defined('BCS_SK') && false === getenv('HTTP_BAE_ENV_SK')) {
throw new BCS_Exception('No secret key was passed into the constructor.');
}
if ($ak && $sk) {
$this->ak = $ak;
$this->sk = $sk;
} elseif (defined('BCS_AK') && defined('BCS_SK') && strlen(BCS_AK) > 0 && strlen(BCS_SK) > 0) {
$this->ak = BCS_AK;
$this->sk = BCS_SK;
} elseif (false !== getenv('HTTP_BAE_ENV_AK') && false !== getenv('HTTP_BAE_ENV_SK')) {
$this->ak = getenv('HTTP_BAE_ENV_AK');
$this->sk = getenv('HTTP_BAE_ENV_SK');
} else {
throw new BCS_Exception('Construct can not get ak &sk pair, please check!');
}
//valid $hostname
if (null !== $hostname) {
$this->hostname = $hostname;
} elseif (false !== getenv('HTTP_BAE_ENV_ADDR_BCS')) {
$this->hostname = getenv('HTTP_BAE_ENV_ADDR_BCS');
} else {
$this->hostname = self::DEFAULT_URL;
}
}