I am trying to implement the Amazon Web Service Feed we are using into my Codeigniter project through the controller.I can do it through the view fine, but when I try it through the controller I get the following error
Non-existent class: CI_Ec2Client
I have changed the class name from Ec2Client to CI_Ec2Client but no luck. The SDK is located in system/libraries/aws
My controller code is as follows:
require 'aws/aws-autoloader.php';
$this->load->library('aws/Aws/Ec2/Ec2Client');
$ec2Client = Ec2Client::factory(array(
'key' => 'KEY_HERE',
'secret' => 'SECRET_HERE',
'region' => 'us-west-2'
));
$result = $ec2Client->describeInstances(array(
'MaxResults' => '1000'
));
This throws the error. However my view code is pretty much similar and it works fine.
require 'aws/aws-autoloader.php';
use Aws\Ec2\Ec2Client;
$ec2Client = Ec2Client::factory(array(
'key' => 'KEY_HERE',
'secret' => 'SECRET_HERE',
'region' => 'us-west-2'
));
$result = $ec2Client->describeInstances(array(
'MaxResults' => '1000'
));
The reason I am trying to load it through my controller is so I can call it every few minutes through an ajax call.
Any idea what I am doing wrong? Can't seem to figure it out!
Aucun commentaire:
Enregistrer un commentaire