Welcome Guest, Not a member yet? Register   Sign In
aws sdk for php 2 integration with codeigniter
#5

[eluser]Greg767[/eluser]
So, for anyone interested, here is how I did it (on Win8 and WAMP):
Install Composer for windows.
For a successful installation you need to enable php-openssl and php-curl in WAMP. This need to be enabled also in wamp/bin/php/php.ini and not only on WAMP user interface. Also I chose to install composer with the Explorer plugin, this way you can have Composer in the contextual menu in explorer (right-click).

In the project root directory (I use netbeans) create a composer.json and put this as content:
Code:
{
    "require": {
        "aws/aws-sdk-php": "2.*"
}
}

Right-click in the project's root folder (where the json is) and choose Composer Install from the right-click menu.
This will install everything.



In the root folder in index.php add this line:
Code:
require_once './vendor/autoload.php';

In application/config create aws_sdk.php with the following content:
Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$config['aws_access_key']="PUT_HERE_YOUR_KEY";
$config['aws_secret_key']="PUT_HERE_YOUR_SECRET_KEY";

In application/libraries create Aws_sdk folder.

In application/libraries/Aws_sdk create Aws_sdk.php with the following:

Code:
<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

use Aws\Sns\SnsClient; //here you define what module(s) you want to use

class Aws_sdk {

    public $snsClient;
    public $ci;

    public function __construct() {
        $this->ci = & get_instance();
        $this->ci->load->config('aws_sdk');
        $this->snsClient = SnsClient::factory(array(
                    'key' => $this->ci->config->item('aws_access_key'),
                    'secret' => $this->ci->config->item('aws_secret_key'),
                    'region' => "us-west-2"
        )); //Change this to instantiate the module you want. Look at the documentation to find out what parameters you need.
    }

    public function __call($name, $arguments = null) {
        if (!property_exists($this, $name)) {
            return call_user_func_array(array($this->snsClient, $name), $arguments);
        } //Change this accordingly too
    }

//Write your methods to call AWS functionality
    public function SendPushNotification($message, $target)
    {
        $result = $this->snsClient->publish(array(
            'TargetArn' => $target,
            'Message' => $message
        ));
    }
}

Thats all. It worked for me.

Greg

PS.: Original source of this solution: https://github.com/fcosrno/aws-sdk-php-codeigniter


Messages In This Thread
aws sdk for php 2 integration with codeigniter - by El Forum - 03-23-2013, 06:50 AM
aws sdk for php 2 integration with codeigniter - by El Forum - 05-03-2013, 04:53 AM
aws sdk for php 2 integration with codeigniter - by El Forum - 08-09-2013, 10:15 AM
aws sdk for php 2 integration with codeigniter - by El Forum - 08-26-2014, 02:23 AM
aws sdk for php 2 integration with codeigniter - by El Forum - 08-28-2014, 01:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB