/** * @param ASNS_Notification $notification * @param string $topic_arn * @param string $key * @param string $secret * @param string $region * @return Guzzle\Service\Resource\Model */ private static function push_to_sns(ASNS_Notification $notification, $topic_arn, $key, $secret, $region) { $args = array('credentials' => array('key' => $key, 'secret' => $secret), 'region' => $region, 'version' => '2010-03-31'); $sdk = new Aws\Sdk($args); $sns_client = $sdk->createSNS(); return $sns_client->publish(array('TopicArn' => $topic_arn, 'Message' => $notification->get_pn_text())); }
<?php require 'vendor/autoload.php'; use Aws\CloudWatch\CloudWatchClient; $key = "your_access_key"; $secret = "your_access_secret"; $region = "us-west-2"; $version = "latest"; $interval = 15; // Users/rajamani/Downloads/devserver/bill/vendor/aws/aws-sdk-php/src // Use the us-west-2 region and latest version of each client. $sharedConfig = ['region' => $region, 'version' => $version, 'credentials' => array('key' => $key, 'secret' => $secret), 'key' => $key, 'secret' => $secret]; // Create an SDK class used to share configuration across clients. $sdk = new Aws\Sdk($sharedConfig); $client = $sdk->createCloudWatch(); function grabber($client, $tablename, $metric) { $output = array(); date_default_timezone_set('America/Los_Angeles'); $results = $client->getMetricStatistics(array('Namespace' => 'AWS/ECS', 'MetricName' => $metric, 'Dimensions' => array(array('Name' => 'TableName', 'Value' => $tablename)), 'StartTime' => strtotime('-1 days'), 'EndTime' => strtotime('now'), 'Period' => 300, 'Statistics' => array('Minimum', 'Maximum', 'Average', 'Sum'))); //echo 'GRABBER='.serialize($results); print "-------------------------------------------\n"; print " {$metric}\n"; print "-------------------------------------------\n"; $output = array('key' => $metric, 'min' => 1, 'max' => 5, 'avg' => 2, 'sum' => 2, 'cumulate' => true, 'units' => 'count'); /* foreach ($results as $result){ //echo 'RESULT='.serialize($result); if (is_array($result) && array_key_exists('Datapoints', $result)){ foreach ( $result['Datapoints'] as $item ) { $min = $item['Minimum'];
<?php require 'database/aws/aws-autoloader.php'; $sdk = new Aws\Sdk(['region' => 'us-east-1', 'version' => 'latest', 'endpoint' => 'https://dynamodb.us-east-1.amazonaws.com', 'credentials' => ['key' => 'AKIAI6QGMWIWAPXYQISQ', 'secret' => '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']]); $dynamodb = $sdk->createDynamoDb(); $response = $dynamodb->scan(['TableName' => 'Recipes']); ?> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> <title>Echo Chef</title> <!-- Bootstrap Core CSS --> <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css"> <!-- Custom Fonts --> <link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'> <link href='http://fonts.googleapis.com/css?family=Merriweather:400,300,300italic,400italic,700,700italic,900,900italic' rel='stylesheet' type='text/css'> <link rel="stylesheet" href="font-awesome/css/font-awesome.min.css" type="text/css"> <!-- Plugin CSS --> <link rel="stylesheet" href="css/animate.min.css" type="text/css"> <!-- Custom CSS --> <link rel="stylesheet" href="css/creative.css" type="text/css">
echo '<li class="instructor">' . $instructor . '</li>'; } } ?> </ul> <h2> <?php echo (count($_SESSION["TEXTBOOKS"]) == 0 ? "No " : "") . "Required/Recommended " . (count($_SESSION["TEXTBOOKS"]) > 1 ? "Textbooks" : "Textbook"); ?> </h2> <ul> <?php //Amazon Web Service API Implementation $s3 = new Aws\S3\S3Client(['version' => 'latest', 'region' => 'us-west-2']); $sharedConfig = ['region' => 'us-west-2', 'version' => 'latest']; $sdk = new Aws\Sdk($sharedConfig); $client = $sdk->createS3(); foreach ($_SESSION["TEXTBOOKS"] as $textbook) { if (!empty($textbook) && $textbook != null) { $isbn_used = ""; //(!empty($textbook['ISBN_v10'])) ? substr($textbook['ISBN_v10'], 8) : substr($textbook['ISBN_v13'], 11); $linkId = ""; echo '<li class="book-result custom-box-shadow">'; $lookup = null; $thumbnail_url = ""; if (!empty($textbook['ISBN_v10'])) { $isbn_used = substr($textbook['ISBN_v10'], 8); } else { if ($lookup == null && !empty($textbook['ISBN_v13'])) { $isbn_used = substr($textbook['ISBN_v13'], 11); }
/** * レジからの注文データを取り込む。 * @param $params バッチ自体のパラメータ * @param $data バッチで引き回すデータ * @return バッチで引き回すデータ */ protected function importOrders($params, $data) { try { // Use the us-west-2 region and latest version of each client. $sharedConfig = array('region' => 'ap-northeast-1', 'version' => 'latest'); // Create an SDK class used to share configuration across clients. $sdk = new Aws\Sdk($sharedConfig); // Create an Amazon S3 client using the shared configuration data. $client = $sdk->createS3(); if (count($params) > 3) { if ($params[3] == "today") { $time = time(); } elseif ($params[3] == "yesterday") { $time = strtotime("-1 day"); } else { $time = strtotime($params[3]); } } else { $time = time(); } // Get the object $result = $client->getObject(array('Bucket' => "oder-report", 'Key' => "150/" . date("Ym", $time) . "/sales-" . date("Y-m-d", $time) . ".csv")); Vizualizer_Logger::writeDebug($result['Body']); $lines = explode("\n", $result['Body']); $columns = array(); $data = array(); foreach ($lines as $index => $line) { if (!empty($line)) { if ($index > 0) { $item = str_getcsv($line); $record = array(); foreach ($columns as $i => $key) { $record[$key] = $item[$i]; } $data[] = $record; } else { $columns = str_getcsv($line); } } } Vizualizer_Logger::writeDebug(print_r($data, true)); $sets = array(); foreach ($data as $item) { if ($item["type"] == "summary") { // トランザクションの開始 $connection = Vizualizer_Database_Factory::begin("stock"); try { $loader = new Vizualizer_Plugin("stock"); $model = $loader->loadModel("Order"); $model->findByPrimaryKey($item["order_id"]); if (!($model->order_id > 0)) { $model = $loader->loadModel("Order", array("order_id" => $item["order_id"])); } $model->user_id = $item["user_id"]; $model->payment_type = $item["payment_type"]; $model->order_date = $item["purchase_date"]; $model->price = $item["price"]; $model->save(); // エラーが無かった場合、処理をコミットする。 Vizualizer_Database_Factory::commit($connection); } catch (Exception $e) { Vizualizer_Database_Factory::rollback($connection); throw new Vizualizer_Exception_Database($e); } } if ($item["type"] == "set") { $sets[$item["order_id"] . "-" . $item["set_id"]] = $item; // トランザクションの開始 $connection = Vizualizer_Database_Factory::begin("stock"); try { $loader = new Vizualizer_Plugin("stock"); $model = $loader->loadModel("OrderDetail"); $model->order_id = $item["order_id"]; $model->set_id = $item["set_id"]; $model->set_menu_name = $item["set_menu_name"]; $model->order_date = $item["purchase_date"]; $model->price = $item["price"]; $model->quantity = $item["count"]; $model->save(); $model = $loader->loadModel("Menu"); $model->findBy(array("set_id" => $item["set_id"], "choice_id" => 0)); $model->set_id = $item["set_id"]; $model->set_menu_name = $sets[$item["order_id"] . "-" . $item["set_id"]]["set_menu_name"]; $model->menu_name = $item["menu_name"]; $model->price = $item["price"]; $model->fixed_flg = "1"; $model->save(); // エラーが無かった場合、処理をコミットする。 Vizualizer_Database_Factory::commit($connection); } catch (Exception $e) { Vizualizer_Database_Factory::rollback($connection); throw new Vizualizer_Exception_Database($e); } // 在庫の引き当てを実施 $model = $loader->loadModel("OrderDetail"); $models = $model->findAllBy(array("set_id" => $item["set_id"], "ne:provision_flg" => "1")); foreach ($models as $model) { $model->provision(); } } if ($item["type"] == "choice") { // トランザクションの開始 $connection = Vizualizer_Database_Factory::begin("stock"); try { $loader = new Vizualizer_Plugin("stock"); $model = $loader->loadModel("OrderDetail"); $model->order_id = $item["order_id"]; $model->set_id = $item["set_id"]; $model->choice_id = $item["choice_id"]; $model->set_menu_name = $sets[$item["order_id"] . "-" . $item["set_id"]]["set_menu_name"]; $model->menu_name = $item["menu_name"]; $model->price = $item["price"]; $model->quantity = $sets[$item["order_id"] . "-" . $item["set_id"]]["count"]; $model->save(); $model = $loader->loadModel("Menu"); $model->findBy(array("set_id" => $item["set_id"], "choice_id" => $item["choice_id"])); $model->set_id = $item["set_id"]; $model->choice_id = $item["choice_id"]; $model->set_menu_name = $sets[$item["order_id"] . "-" . $item["set_id"]]["set_menu_name"]; $model->menu_name = $item["menu_name"]; $model->price = $item["price"]; $model->fixed_flg = "1"; $model->save(); // エラーが無かった場合、処理をコミットする。 Vizualizer_Database_Factory::commit($connection); } catch (Exception $e) { Vizualizer_Database_Factory::rollback($connection); throw new Vizualizer_Exception_Database($e); } // 在庫の引き当てを実施 $model = $loader->loadModel("OrderDetail"); $models = $model->findAllBy(array("set_id" => $item["set_id"], "choice_id" => $item["choice_id"], "ne:provision_flg" => "1")); foreach ($models as $model) { $model->provision(); } } } } catch (S3Exception $e) { echo $e->getMessage() . "\n"; } return $data; }
function __construct() { $sdk = new Aws\Sdk(array('region' => S3Settings::S3_REGION, 'version' => S3Settings::S3_VERSION, 'credentials' => array('key' => S3Settings::S3_KEY, 'secret' => S3Settings::S3_SECRET))); // create client $this->client = $sdk->createS3(); }