This repository has been archived by the owner on Mar 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 97
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.
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)
<?php
// ...
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;
$this->country($country);
}
- Call the library as follows:
<?php
// ...
$params = array(AWS_API_KEY, AWS_API_SECRET_KEY, 'co.uk', AWS_ASSOCIATE_ID);
$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->category($category)->search($search);
And thats it!