Exeu/Amazon-ECS-PHP-Library — Issue #20: CodeIgniter version
Author: samedney
Created: 2011-10-10 19:57:41+00:00
State: open

This is not really an issue - just a point of discussion and I couldn't find where to add it.

I have been using this class as-is for a while - and it has been great, but Im not 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.

----
Changes:

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)
```php
public function __construct($params)
{

$accessKey = $params[0];
$secretKey = $params[1];
$country = $params[2];
$associateTag = $params[3];
$category = $params[4];

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;
$this->requestConfig['category'] = $category;
$this->country($country);
}
```

4) Call the library as follows:
```php

$params = array(AWS_API_KEY, AWS_API_SECRET_KEY, 'co.uk', AWS_ASSOCIATE_ID, $category);

$this->load->library("AmazonECS", $params);

//tell the amazon class that we want an array, not an object
$this->amazonecs->setReturnType(AmazonECS::RETURN_TYPE_ARRAY);

$response = $this->amazonecs->search($search);
```

And thats it!