/**
  * Get the AWS SDK SQS instance (pseudo singleton).
  *
  * @return AWS SQS instance.
  */
 public function getInstance()
 {
     if ($this->_sqs === null) {
         if ($this->_accessKey === null && $this->_secretKey === null) {
             // If you don't specify the key and secret, then the SDK will use the IAM role of the machine for the credentials.
             if ($this->_awsApiVersion == 2) {
                 $this->_sqs = Aws\Sqs\SqsClient::factory(array('region' => $this->_region));
             } else {
                 $this->_sqs = Aws\Sqs\SqsClient::factory(array('region' => $this->_region, 'version' => '2012-11-05'));
             }
         } else {
             if ($this->_awsApiVersion == 2) {
                 $this->_sqs = Aws\Sqs\SqsClient::factory(array('key' => $this->_accessKey, 'secret' => $this->_secretKey, 'region' => $this->_region));
             } else {
                 $this->_sqs = Aws\Sqs\SqsClient::factory(array('region' => $this->_region, 'version' => '2012-11-05', 'credentials' => array('key' => $this->_accessKey, 'secret' => $this->_secretKey)));
             }
         }
     }
     return $this->_sqs;
 }
예제 #2
0
 /**
  * @param string $name
  * @return Aws
  */
 public function __get($name)
 {
     switch ($name) {
         case 'sqs':
             if (empty($this->sqs_client)) {
                 $this->sqs_client = Aws\Sqs\SqsClient::factory(array('key' => $this->CI->config->item('sqs_access_key_id'), 'secret' => $this->CI->config->item('sqs_secret_key'), 'region' => $this->CI->config->item('aws_region')));
             }
             $this->client = $this->sqs_client;
             break;
         case 's3':
             if (empty($this->s3_client)) {
                 $this->s3_client = Aws\S3\S3Client::factory(array('key' => $this->CI->config->item('s3_access_key_id'), 'secret' => $this->CI->config->item('s3_secret_key'), 'region' => $this->CI->config->item('aws_region')));
             }
             $this->client = $this->s3_client;
             break;
         default:
             break;
     }
     return $this;
 }