Skip to content

Use as a CodeIgniter library

Exeu edited this page Dec 20, 2011 · 3 revisions

I have been using this class as-is for a while - and it has been great, but Im now converting my site to use the CodeIgniter framework.

I have managed to get the AmazonECS to work as a library - by changing about 6 lines of code. Im not sure I had done things in the best way - but happy to share these changes with anyone, should they want to go down the codeigniter route.

Thanks again for an amazing class.


  1. Rename the AmazonECS.class.php to just AmazonECS.php

  2. Add the file to the application/libraries folder

  3. Change some code within the class as follows:

LINE 71 (construct)

// ...

public function __construct($params)
    $accessKey    = $params[0];
    $secretKey    = $params[1];
    $country      = $params[2];
    $associateTag = $params[3];
    if (empty($accessKey) || empty($secretKey))
      throw new Exception('No Access Key or Secret Key has been set');

    $this->requestConfig['accessKey']     = $accessKey;
    $this->requestConfig['secretKey']     = $secretKey;
    $this->requestConfig['associateTag']  = $associateTag;
  1. Call the library as follows:
// ...

$this->load->library("AmazonECS", $params);
//tell the amazon class that we want an array, not an object
$response = $this->amazonecs->category($category)->search($search);

And thats it!

You can’t perform that action at this time.