public function testCreatesTopic() { self::log('Creating topic'); $result = $this->sns->createTopic(array('Name' => self::$topic)); $this->assertArrayHasKey('TopicArn', $result->toArray()); $this->assertArrayHasKey('ResponseMetadata', $result->toArray()); self::$topicArn = $result['TopicArn']; return self::$topicArn; }
/** * Creates a SNS Topic and returns the ARN * * The create method for the SNS Topics is idempotent - if the topic already * exists, this method will return the Topic ARN of the existing Topic. * * * @return false|null */ public function createTopic() { if (!$this->options['push_notifications']) { return false; } $result = $this->sns->createTopic(['Name' => $this->getNameWithPrefix()]); $this->topicArn = $result->get('TopicArn'); $key = $this->getNameWithPrefix() . '_arn'; $this->cache->save($key, $this->topicArn); $this->log(200, "Created SNS Topic", ['TopicARN' => $this->topicArn]); }
$phone = $_POST['phone']; $s3rawurl = $url; $filename = basename($_FILES['userfile']['name']); $s3finishedurl = $finishedurl; $status = 0; $date = '2015-11-10 12:00:00'; $stmt->bind_param("sssssii", $email, $phone, $filename, $s3rawurl, $s3finishedurl, $state, $date); if (!$stmt->execute()) { echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error; } printf("%d Row inserted.\n", $stmt->affected_rows); /* explicit close recommended */ $stmt->close(); $link->real_query("SELECT * FROM arshadsTable"); $res = $link->use_result(); echo "Result set order...\n"; while ($row = $res->fetch_assoc()) { echo $row['ID'] . " " . $row['email'] . " " . $row['phone']; } $sns = new Aws\Sns\SnsClient(['version' => 'latest', 'region' => 'us-east-1']); $result = $sns->createTopic(['Name' => 'My-New-SNS-topic']); $topicArn = $result['TopicArn']; echo "Topic ARN is ::: {$topicArn}"; $result = $sns->setTopicAttributes(['AttributeName' => 'DisplayName', 'AttributeValue' => 'MP2-SNS-TOPIC', 'TopicArn' => $topicArn]); $result = $sns->subscribe(['Endpoint' => $email, 'Protocol' => 'email', 'TopicArn' => $topicArn]); sleep(30); //=======================sleep for 30 seconds so that the user can subscribe================== $result = $sns->publish(['TopicArn' => $topicArn, 'Subject' => 'Image uploaded', 'Message' => 'Congratulations! Your image has been successfully uploaded']); $link->close(); header('Location: gallery.php'); exit;
<?php session_start(); require 'vendor/autoload.php'; use Aws\Sns\SnsClient; //Create topic and subscribe to it $email = $_POST['email']; $sns = new Aws\Sns\SnsClient(array('version' => 'latest', 'region' => 'us-east-1')); $ArnArray = $sns->createTopic(['Name' => 'mp2-jgl-pict']); $Arn = $ArnArray['TopicArn']; $settopicAttributes = $sns->setTopicAttributes(array('TopicArn' => "{$Arn}", 'AttributeName' => 'DisplayName', 'AttributeValue' => 'mp2-jgl-pict')); $topicAttributes = $sns->getTopicAttributes(array('TopicArn' => "{$Arn}", 'AttributeName' => 'DisplayName', 'AttributeValue' => 'mp2-jgl-pict')); $listSubscriptions = $sns->listSubscriptionsByTopic(array('TopicArn' => $Arn)); $subscribe = $sns->subscribe(array('TopicArn' => $Arn, 'Protocol' => 'email', 'Endpoint' => $email)); ?> <html> <body style="background-color:LemonChiffon"> <center> <h1 style=> Subscription confirmed</h1> <h2> <?php echo $email; ?> </h2> <h3> <?php echo "\r\n"; echo "You will receive an email you must confirm"; ?> </h3><a href="/index.php">Index page</a></center>
/** * Create a topic * @param string $name Topic name * @return string The topic ARN * @deprecated use SnsClient directly to subscribe */ public function createTopic($name) { $res = $this->sns->createTopic(['Name' => $name]); return $res['TopicArn']; }
/** * @Given /^I create a new topic "([^"]*)"$/ * @param string $name */ public function iCreateANewTopic($name) { $this->result = $this->sns->createTopic(['Name' => $this->getRandomizedTopicName($name)]); PHPUnit_Framework_Assert::assertTrue($this->result->hasKey('TopicArn')); $this->arns[$name] = $this->result->get('TopicArn'); }
$userS3finishedurl = $url; $status = 0; $issubscribed = 0; mysqli_query($link, "INSERT INTO jssUserImages (idTable,userNameTable,userEmailTable,userTelephoneTable,rawS3URLTable,finishedS3URLTable,fileNameTable,stateTable,dateTable) \nVALUES (NULL,'{$name}','{$email}','{$phone}','{$userS3rawurl}','{$userS3finishedurl}','{$filename}','{$status}','NULL')"); $stmt->bind_param("sssssii", $name, $email, $phone, $userS3rawurl, $userS3finishedurl, $filename, $status, $issubscribed); //execution of SQL insert if (!$stmt->execute()) { echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error; } printf("%d Row inserted.\n", $stmt->affected_rows); /* explicit close recommended */ $stmt->close(); $link->real_query("SELECT * FROM jssUserImages"); $res = $link->use_result(); echo "Result set order...\n"; while ($row = $res->fetch_assoc()) { print $row['idTable'] . " " . $row['userEmailTable'] . " " . $row['userTelephoneTable']; } //using aws sns use Aws\Sns\SnsClient; $sns = new Aws\Sns\SnsClient(['version' => 'latest', 'region' => 'us-east-1', 'credentials' => ['key' => '', 'secret' => '']]); //creating the sns topic $result = $sns->createTopic(['Name' => 'JSSSNS']); $snsARN = $result['TopicArn']; //subscribing user to sns $result = $sns->subscribe(['Endpoint' => $email, 'Protocol' => 'email', 'TopicArn' => $snsARN]); //push out the subscription $result = $sns->publish(['Message' => 'Hello! This is an automated message informing you that your file has been uploaded!', 'Subject' => 'File Uploaded to AWS S3 bucket', 'TopicArn' => $snsARN]); //this is for the gallery session page $_SESSION['gallerySession'] = TRUE; $link->close();