BaiduBCS::__construct PHP Method

__construct() public method

构造函数
public __construct ( string $ak = null, string $sk = null, string $hostname = null )
$ak string 云存储公钥
$sk string 云存储私钥
$hostname string 云存储Api访问地址
    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;
        }
    }