Amazon SDK

Hi guys, I am testing out the cloud offering from Amazon and want to integrate the SDK from them into my Yii application.

The SDK is located here

The particular item I am testing right now is the AmazonSES offering.

What I have done:

Added the following to my index.php




$awssdk=dirname(__FILE__).'/../awssdk/sdk-1.2.3/sdk.class.php';

require_once($awssdk);



I have verified that this location is correct and it’s loading from index.php

When I try to make a call to the following I get the error "include(AmazonSES.php): failed to open stream: No such file or directory"


$email = new AmazonSES();

Can someone enlighten me on what I am doing wrong?

Reading a little bit deeper in the tutorials I found this and followed it. I moved the SDK to vendors/amazon

I added the following




Yii::import('application.vendors.*');

require_once('amazon/sdk/sdk.class.php');



It’s still not working properly. Any ideas?

So after fighting with this for an hour or so I have a page working, but is this really how I would have to do this for any function I want to use for AmazonSDK?




Yii::import('application.vendors.*');

    require_once('amazon/sdk/sdk.class.php');

    require_once('amazon/sdk/services/ses.class.php');

    require_once('amazon/sdk/utilities/utilities.class.php');

    require_once('amazon/sdk/utilities/complextype.class.php');

    require_once('amazon/sdk/lib/requestcore/requestcore.class.php');

    require_once('amazon/sdk/utilities/request.class.php');

    require_once('amazon/sdk/utilities/response.class.php');

    require_once('amazon/sdk/utilities/simplexml.class.php');


    $email = new AmazonSES();


    $response = $email->send_email(

        'test@test.com', // Source (aka From)

        array('ToAddresses' => 'test@test.com'), // Destination (aka To)

        array( // Message (short form)

            'Subject.Data' => 'Email Test ' . time(),

            'Body.Text.Data' => 'This is a simple test message ' . time()

        )

    );


    // Success?

    var_dump($response->isOK());

So after scouring the web and pulling information together from several sites I think I finally have the proper way. Documenting it here in the event someone else needs this

I added the following code in index.php (NOTE: Yii::$classMap between require_once($yii) and Yii::createWebApplication($config)->run())




require_once($yii);


// Map classes for Amazon Cloud Computing Environment

Yii::$classMap=array(

    'AmazonSES'=>'sdk/services/ses.class.php',

    'CFRuntime'=>'sdk/sdk.class.php',

    'CFUtilities'=>'sdk/utilities/utilities.class.php',

    'CFComplexType'=>'sdk/utilities/complextype.class.php',

    'RequestCore'=>'sdk/lib/requestcore/requestcore.class.php',

    'CFRequest'=>'sdk/utilities/request.class.php',

    'CFResponse'=>'sdk/utilities/response.class.php',

    'CFSimpleXML'=>'sdk/utilities/simplexml.class.php',

);


Yii::createWebApplication($config)->run();



I then updated ‘import’ in config/main.php to import where I unzipped the SDK for Amazon




'import'=>array(

	...

        'application.vendors.amazon.*',



All seems to be working fine. Cheers!

Strange but not works for me.

I got:


include(Z:/home/myapp/www/protected/vendors/amazon/services/ses.class.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory 

I have the next in index.php:


$pathToSES = dirname(__FILE__) . '/protected/vendors/amazon/';

Yii::$classMap=array(

    'AmazonSES'=>$pathToSES.'services/ses.class.php',

    'CFRuntime'=>$pathToSES.'sdk.class.php',

    'CFUtilities'=>$pathToSES.'utilities/utilities.class.php',

    'CFComplexType'=>$pathToSES.'utilities/complextype.class.php',

    'RequestCore'=>$pathToSES.'lib/requestcore/requestcore.class.php',

    'CFRequest'=>$pathToSES.'utilities/request.class.php',

    'CFResponse'=>$pathToSES.'utilities/response.class.php',

    'CFSimpleXML'=>$pathToSES.'utilities/simplexml.class.php',

);

and in main.php:


	'import'=>array(

        ...

        'application.vendors.amazon.*',

	),



This seems to work for me. At the moment, I don’t think there’s anything else except for these three lines, but it’s been a while since I’ve looked into this old app…


spl_autoload_unregister(array('YiiBase','autoload'));

require_once dirname(__FILE__) . "/amazons3/sdk.class.php";

spl_autoload_register(array('YiiBase', 'autoload'));

Hi, I was reading about this to get my SES up and running. It seems that you need to define each and every class used in the class map, as you have done, for future people though, there’s quite a lot that needs to be defined on the newer SDK that isn’t mentioned here. Your best bet is defining the whole SDK in a class map right from the start. It is ugly as hell and I am still hoping for someone to tell me that I’m an idiot and there’s a better way to do it, but for now this topic has some details on using the grep plugin to take some of the pain out of the process (don’t be tempted to use the list supplied by one of the posters, this also has some classes missing).

This worked perfectly for me. Thanks!