SIGN IN SIGN UP

Welcome to the AWS Code Examples Repository. This repo contains code examples used in the AWS documentation, AWS SDK Developer Guides, and more. For more information, see the Readme.md file below.

0 0 50 Java
2018-12-28 10:35:52 -08:00
<?php
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
2018-12-28 10:35:52 -08:00
/*
* ABOUT THIS PHP SAMPLE: This sample is part of the SDK for PHP Developer Guide topic
*
*
*/
2019-02-05 21:40:13 -08:00
// snippet-start:[sns.php.set_topic_attributes.complete]
// snippet-start:[sns.php.set_topic_attributes.import]
2018-12-28 10:35:52 -08:00
require 'vendor/autoload.php';
2018-12-28 10:35:52 -08:00
use Aws\Exception\AwsException;
2019-02-05 21:40:13 -08:00
use Aws\Sns\SnsClient;
2019-02-05 21:40:13 -08:00
// snippet-end:[sns.php.set_topic_attributes.import]
2018-12-28 10:35:52 -08:00
/**
* Configure the message delivery status attributes for an Amazon SNS Topic.
*
* This code expects that you have AWS credentials set up per:
* https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials.html
*/
2019-02-05 21:40:13 -08:00
// snippet-start:[sns.php.set_topic_attributes.main]
2018-12-28 10:35:52 -08:00
$SnSclient = new SnsClient([
'profile' => 'default',
'region' => 'us-east-1',
'version' => '2010-03-31'
]);
$attribute = 'Policy | DisplayName | DeliveryPolicy';
$value = 'First Topic';
$topic = 'arn:aws:sns:us-east-1:111122223333:MyTopic';
2018-12-28 10:35:52 -08:00
try {
$result = $SnSclient->setTopicAttributes([
'AttributeName' => $attribute,
'AttributeValue' => $value,
'TopicArn' => $topic,
]);
var_dump($result);
} catch (AwsException $e) {
// output error message if fails
error_log($e->getMessage());
2019-02-05 21:40:13 -08:00
}
2019-02-05 21:40:13 -08:00
// snippet-end:[sns.php.set_topic_attributes.main]
// snippet-end:[sns.php.set_topic_attributes.complete]