2018-12-27 15:37:17 -08:00
< ? php
2018-12-28 10:35:52 -08:00
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2018-12-27 15:37:17 -08:00
// SPDX-License-Identifier: Apache-2.0
2024-02-05 10:49:20 -07:00
2018-12-27 15:37:17 -08:00
/*
* ABOUT THIS PHP SAMPLE: This sample is part of the SDK for PHP Developer Guide topic
*
*
*/
2019-02-15 19:42:12 -08:00
// snippet-start:[sns.php.list_topics.complete]
// snippet-start:[sns.php.list_topics.import]
2018-12-27 15:37:17 -08:00
require 'vendor/autoload.php' ;
2024-02-05 10:49:20 -07:00
2018-12-27 15:37:17 -08:00
use Aws\Exception\AwsException ;
2019-02-05 21:40:13 -08:00
use Aws\Sns\SnsClient ;
2024-02-05 10:49:20 -07:00
2019-02-15 19:42:12 -08:00
// snippet-end:[sns.php.list_topics.import]
2024-02-05 10:49:20 -07:00
2018-12-27 15:37:17 -08:00
/**
* Returns a list of the requester's topics from your AWS SNS account in the region specified.
*
* 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
*/
2024-02-05 10:49:20 -07:00
2019-02-15 19:42:12 -08:00
// snippet-start:[sns.php.list_topics.main]
2018-12-27 15:37:17 -08:00
$SnSclient = new SnsClient ([
'profile' => 'default' ,
'region' => 'us-east-1' ,
'version' => '2010-03-31'
]);
2024-02-05 10:49:20 -07:00
2018-12-27 15:37:17 -08:00
try {
$result = $SnSclient -> listTopics ();
var_dump ( $result );
} catch ( AwsException $e ) {
// output error message if fails
error_log ( $e -> getMessage ());
2019-02-05 21:40:13 -08:00
}
2024-02-05 10:49:20 -07:00
2019-02-15 19:42:12 -08:00
// snippet-end:[sns.php.list_topics.main]
// snippet-end:[sns.php.list_topics.complete]
2019-01-18 00:02:57 -08:00
// snippet-sourceauthor:[jschwarzwalder]