CodeIgniter version
samedney opened this issue · 4 comments
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 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.
Changes:
- Rename the AmazonECS.class.php to just AmazonECS.php
- Add the file to the application/libraries folder
- 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];
$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);
}
- Call the library as follows:
$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!
NOTE TO ALL: I have not tested this thoroughly as yet - but thought I would post this in case anyone else wants to use this class inside Code Igniter.
Thanks for you efforts :)
Maybe you could write this as a wiki page?
I think an issue is the wrong place for that ;)
Cheers
Yeah -sorry! Dont know why I didnt do this before. I have added a few Wiki pages already. Clearly my mind was elsewhere. :)
Wiki article added. Please critique the changes I have made - as Im not sure if there is a better way to include the $category etc. Thanks again.