기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
Amazon SNS 전화번호 및 구독 관리
SNSAmazon은 계정에서 SMS 메시지를 받는 사람을 관리하기 위한 몇 가지 옵션을 제공합니다. 제한된 빈도로 계정에서 SMS 메시지 수신을 거부한 전화번호를 수신하도록 선택할 수 있습니다. 구독에 메시지를 더 이상 보내지 않으려면 SMS 구독이나 구독에 게시되는 주제를 제거하면 됩니다.
메시지 수신 옵트아웃 SMS
현지 법률 및 규정 (예: 미국 및 캐나다) 에서 요구하는 경우 SMS 수신자는 장치를 사용하여 다음 중 하나를 포함하여 메시지에 회신하여 수신을 거부할 수 있습니다.
-
ARRET(프랑스어)
-
CANCEL
-
END
-
OPT-OUT
-
OPTOUT
-
QUIT
-
REMOVE
-
STOP
-
TD
-
UNSUBSCRIBE
옵트아웃하려면 수신자는 Amazon이 메시지를 전송할 때 SNS 사용한 것과 동일한 발신번호로 회신해야 합니다. 수신을 거부하면 전화번호를 AWS 계정 옵트인하지 않는 한 수신자는 더 이상 귀하의 SMS 메시지를 수신하지 않습니다.
해당 전화번호가 Amazon SNS 주제를 구독하고 있는 경우 옵트아웃해도 구독이 제거되지는 않지만 전화번호를 옵트인하지 않으면 해당 구독으로 SMS 메시지가 전송되지 않습니다.
콘솔을 사용한 전화번호 및 구독 관리
Amazon SNS 콘솔을 사용하여 계정에서 SMS 메시지를 수신하는 전화번호를 제어할 수 있습니다.
옵트아웃한 전화번호 옵트인
계정에서 SMS 메시지 수신을 거부한 전화번호를 볼 수 있으며, 해당 전화번호를 선택하여 메시지 전송을 재개할 수 있습니다.
30일에 한 번만 전화번호를 옵트인할 수 있습니다.
Amazon SNS 콘솔에
로그인합니다. -
콘솔 메뉴에서 지역 선택기를 SMS메시징을 지원하는 지역으로 설정합니다.
-
탐색 패널에서 문자 메시지 (SMS) 를 선택합니다.
-
문자 메시지 (SMS) 페이지에서 수신 거부한 전화번호 보기를 선택합니다. [Opted out phone numbers] 페이지에 옵트아웃된 전화번호가 표시됩니다.
-
옵트인하려는 전화번호의 확인란을 선택하고 [Opt in]을 선택합니다. 해당 전화번호는 더 이상 수신 거부되지 않으며 해당 번호로 보내는 SMS 메시지를 받게 됩니다.
구독 삭제 SMS
주제를 게시할 때 해당 전화번호로 SMS 메시지를 보내는 것을 중지하려면 SMS 구독을 삭제하십시오.
-
탐색 창에서 구독을 선택합니다.
-
삭제하려는 구독의 확인란을 선택합니다. 그런 다음 [Actions]를 선택하고 [Delete Subscriptions]를 선택합니다.
-
삭제 창에서 삭제를 선택합니다. Amazon은 구독을 SNS 삭제하고 성공 메시지를 표시합니다.
주제 삭제
메시지를 구독 엔드포인트에 더 이상 게시하지 않으려는 경우 주제를 삭제합니다.
-
탐색 창에서 주제(Topics)를 선택합니다.
-
삭제하려는 주제의 확인란을 선택합니다. 그런 다음 [Actions]를 선택하고 [Delete Topics]를 선택합니다.
-
삭제 창에서 삭제를 선택합니다. Amazon은 주제를 SNS 삭제하고 성공 메시지를 표시합니다.
를 사용하여 전화번호 및 구독을 관리합니다. AWS SDKs
를 사용하여 AWS SDKs Amazon에 프로그래밍 방식으로 SNS 요청하고 계정에서 SMS 메시지를 수신할 수 있는 전화번호를 관리할 수 있습니다.
를 AWS SDK 사용하려면 자격 증명으로 구성해야 합니다. 자세한 내용은 및 도구 참조 안내서의 공유 구성 및 자격 증명 파일을 참조하십시오.AWS SDKs
옵트아웃한 모든 전화번호 보기
수신 거부된 전화번호를 모두 보려면 SNS API Amazon에 ListPhoneNumbersOptedOut
요청을 제출하십시오.
다음 코드 예제는 ListPhoneNumbersOptedOut
의 사용 방법을 보여 줍니다.
- CLI
-
- AWS CLI
-
SMS메시지 수신 거부를 나열하려면
다음
list-phone-numbers-opted-out
예에서는 메시지 수신을 거부한 전화번호를 나열합니다. SMSaws sns list-phone-numbers-opted-out
출력:
{ "phoneNumbers": [ "+15555550100" ] }
-
자세한 API 내용은 AWS CLI 명령 ListPhoneNumbersOptedOut
참조를 참조하십시오.
-
- Java
-
- SDK자바 2.x의 경우
-
참고
더 많은 내용이 있습니다. GitHub AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.sns.SnsClient; import software.amazon.awssdk.services.sns.model.ListPhoneNumbersOptedOutRequest; import software.amazon.awssdk.services.sns.model.ListPhoneNumbersOptedOutResponse; import software.amazon.awssdk.services.sns.model.SnsException; /** * Before running this Java V2 code example, set up your development * environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class ListOptOut { public static void main(String[] args) { SnsClient snsClient = SnsClient.builder() .region(Region.US_EAST_1) .build(); listOpts(snsClient); snsClient.close(); } public static void listOpts(SnsClient snsClient) { try { ListPhoneNumbersOptedOutRequest request = ListPhoneNumbersOptedOutRequest.builder().build(); ListPhoneNumbersOptedOutResponse result = snsClient.listPhoneNumbersOptedOut(request); System.out.println("Status is " + result.sdkHttpResponse().statusCode() + "\n\nPhone Numbers: \n\n" + result.phoneNumbers()); } catch (SnsException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } } }
-
자세한 API 내용은 ListPhoneNumbersOptedOut AWS SDK for Java 2.xAPI참조를 참조하십시오.
-
- PHP
-
- PHP용 SDK
-
참고
더 많은 정보가 있습니다 GitHub. AWS 코드 예제 리포지토리
에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요. require 'vendor/autoload.php'; use Aws\Exception\AwsException; use Aws\Sns\SnsClient; /** * Returns a list of phone numbers that are opted out of receiving SMS messages from your AWS SNS account. * * 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 */ $SnSclient = new SnsClient([ 'profile' => 'default', 'region' => 'us-east-1', 'version' => '2010-03-31' ]); try { $result = $SnSclient->listPhoneNumbersOptedOut(); var_dump($result); } catch (AwsException $e) { // output error message if fails error_log($e->getMessage()); }
-
자세한 정보는 AWS SDK for PHP 개발자 안내서를 참조하십시오.
-
자세한 API 내용은 ListPhoneNumbersOptedOut AWS SDK for PHPAPI참조를 참조하십시오.
-
전화번호가 옵트아웃되었는지 여부 확인
전화번호가 옵트아웃되었는지 확인하려면 SNS API Amazon에 CheckIfPhoneNumberIsOptedOut
요청을 제출하십시오.
다음 코드 예제는 CheckIfPhoneNumberIsOptedOut
의 사용 방법을 보여 줍니다.
- .NET
-
- AWS SDK for .NET
-
참고
더 많은 정보가 있습니다. GitHub AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. using System; using System.Threading.Tasks; using Amazon.SimpleNotificationService; using Amazon.SimpleNotificationService.Model; /// <summary> /// This example shows how to use the Amazon Simple Notification Service /// (Amazon SNS) to check whether a phone number has been opted out. /// </summary> public class IsPhoneNumOptedOut { public static async Task Main() { string phoneNumber = "+15551112222"; IAmazonSimpleNotificationService client = new AmazonSimpleNotificationServiceClient(); await CheckIfOptedOutAsync(client, phoneNumber); } /// <summary> /// Checks to see if the supplied phone number has been opted out. /// </summary> /// <param name="client">The initialized Amazon SNS Client object used /// to check if the phone number has been opted out.</param> /// <param name="phoneNumber">A string representing the phone number /// to check.</param> public static async Task CheckIfOptedOutAsync(IAmazonSimpleNotificationService client, string phoneNumber) { var request = new CheckIfPhoneNumberIsOptedOutRequest { PhoneNumber = phoneNumber, }; try { var response = await client.CheckIfPhoneNumberIsOptedOutAsync(request); if (response.HttpStatusCode == System.Net.HttpStatusCode.OK) { string optOutStatus = response.IsOptedOut ? "opted out" : "not opted out."; Console.WriteLine($"The phone number: {phoneNumber} is {optOutStatus}"); } } catch (AuthorizationErrorException ex) { Console.WriteLine($"{ex.Message}"); } } }
-
자세한 API 내용은 CheckIfPhoneNumberIsOptedOut AWS SDK for .NETAPI참조를 참조하십시오.
-
- CLI
-
- AWS CLI
-
전화번호의 SMS 메시지 수신 거부를 확인하려면
다음
check-if-phone-number-is-opted-out
예시에서는 지정된 전화번호가 현재 AWS 계정으로부터 SMS 메시지를 받지 않도록 설정되어 있는지 확인합니다.aws sns check-if-phone-number-is-opted-out \ --phone-number
+1555550100
출력:
{ "isOptedOut": false }
-
자세한 API 내용은 AWS CLI 명령 CheckIfPhoneNumberIsOptedOut
참조를 참조하십시오.
-
- Java
-
- SDK자바 2.x의 경우
-
참고
더 많은 내용이 있습니다. GitHub AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.sns.SnsClient; import software.amazon.awssdk.services.sns.model.CheckIfPhoneNumberIsOptedOutRequest; import software.amazon.awssdk.services.sns.model.CheckIfPhoneNumberIsOptedOutResponse; import software.amazon.awssdk.services.sns.model.SnsException; /** * Before running this Java V2 code example, set up your development * environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class CheckOptOut { public static void main(String[] args) { final String usage = """ Usage: <phoneNumber> Where: phoneNumber - The mobile phone number to look up (for example, +1XXX5550100). """; if (args.length != 1) { System.out.println(usage); System.exit(1); } String phoneNumber = args[0]; SnsClient snsClient = SnsClient.builder() .region(Region.US_EAST_1) .build(); checkPhone(snsClient, phoneNumber); snsClient.close(); } public static void checkPhone(SnsClient snsClient, String phoneNumber) { try { CheckIfPhoneNumberIsOptedOutRequest request = CheckIfPhoneNumberIsOptedOutRequest.builder() .phoneNumber(phoneNumber) .build(); CheckIfPhoneNumberIsOptedOutResponse result = snsClient.checkIfPhoneNumberIsOptedOut(request); System.out.println( result.isOptedOut() + "Phone Number " + phoneNumber + " has Opted Out of receiving sns messages." + "\n\nStatus was " + result.sdkHttpResponse().statusCode()); } catch (SnsException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } } }
-
자세한 API 내용은 CheckIfPhoneNumberIsOptedOut AWS SDK for Java 2.xAPI참조를 참조하십시오.
-
- JavaScript
-
- SDK JavaScript (v3) 에 대한
-
참고
더 많은 정보가 있습니다. GitHub AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. 별도의 모듈에서 클라이언트를 생성하고 내보냅니다.
import { SNSClient } from "@aws-sdk/client-sns"; // The AWS Region can be provided here using the `region` property. If you leave it blank // the SDK will default to the region set in your AWS config. export const snsClient = new SNSClient({});
SDK및 클라이언트 모듈을 가져와서 호출하십시오API.
import { CheckIfPhoneNumberIsOptedOutCommand } from "@aws-sdk/client-sns"; import { snsClient } from "../libs/snsClient.js"; export const checkIfPhoneNumberIsOptedOut = async ( phoneNumber = "5555555555", ) => { const command = new CheckIfPhoneNumberIsOptedOutCommand({ phoneNumber, }); const response = await snsClient.send(command); console.log(response); // { // '$metadata': { // httpStatusCode: 200, // requestId: '3341c28a-cdc8-5b39-a3ee-9fb0ee125732', // extendedRequestId: undefined, // cfId: undefined, // attempts: 1, // totalRetryDelay: 0 // }, // isOptedOut: false // } return response; };
-
자세한 정보는 AWS SDK for JavaScript 개발자 안내서를 참조하십시오.
-
자세한 API 내용은 CheckIfPhoneNumberIsOptedOut AWS SDK for JavaScriptAPI참조를 참조하십시오.
-
- PHP
-
- PHP용 SDK
-
참고
더 많은 정보가 있습니다 GitHub. AWS 코드 예제 리포지토리
에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요. require 'vendor/autoload.php'; use Aws\Exception\AwsException; use Aws\Sns\SnsClient; /** * Indicates whether the phone number owner has opted out of receiving SMS messages from your AWS SNS account. * * 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 */ $SnSclient = new SnsClient([ 'profile' => 'default', 'region' => 'us-east-1', 'version' => '2010-03-31' ]); $phone = '+1XXX5550100'; try { $result = $SnSclient->checkIfPhoneNumberIsOptedOut([ 'phoneNumber' => $phone, ]); var_dump($result); } catch (AwsException $e) { // output error message if fails error_log($e->getMessage()); }
-
자세한 정보는 AWS SDK for PHP 개발자 안내서를 참조하십시오.
-
자세한 API 내용은 CheckIfPhoneNumberIsOptedOut AWS SDK for PHPAPI참조를 참조하십시오.
-
옵트아웃한 전화번호 옵트인
전화번호를 수신하려면 Amazon에 OptInPhoneNumber
요청을 SNS API 제출하십시오.
30일에 한 번만 전화번호를 옵트인할 수 있습니다.
SMS구독 삭제
Amazon SNS 주제에서 SMS 구독을 삭제하려면 Amazon에 ListSubscriptions
요청을 ARN 제출하여 구독을 신청한 다음 Unsubscribe
요청에 전달하십시오. SNS API ARN
다음 코드 예제는 Unsubscribe
의 사용 방법을 보여 줍니다.
- .NET
-
- AWS SDK for .NET
-
참고
자세한 내용은 다음과 같습니다 GitHub. AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. 구독을 통해 주제 ARN 구독을 취소하세요.
/// <summary> /// Unsubscribe from a topic by a subscription ARN. /// </summary> /// <param name="subscriptionArn">The ARN of the subscription.</param> /// <returns>True if successful.</returns> public async Task<bool> UnsubscribeByArn(string subscriptionArn) { var unsubscribeResponse = await _amazonSNSClient.UnsubscribeAsync( new UnsubscribeRequest() { SubscriptionArn = subscriptionArn }); return unsubscribeResponse.HttpStatusCode == HttpStatusCode.OK; }
-
자세한 API 내용은 참조에서 AWS SDK for .NET API구독 취소를 참조하십시오.
-
- C++
-
- SDKC++의 경우
-
참고
더 많은 정보가 있습니다. GitHub AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. //! Delete a subscription to an Amazon Simple Notification Service (Amazon SNS) topic. /*! \param subscriptionARN: The Amazon Resource Name (ARN) for an Amazon SNS topic subscription. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SNS::unsubscribe(const Aws::String &subscriptionARN, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SNS::SNSClient snsClient(clientConfiguration); Aws::SNS::Model::UnsubscribeRequest request; request.SetSubscriptionArn(subscriptionARN); const Aws::SNS::Model::UnsubscribeOutcome outcome = snsClient.Unsubscribe(request); if (outcome.IsSuccess()) { std::cout << "Unsubscribed successfully " << std::endl; } else { std::cerr << "Error while unsubscribing " << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
-
자세한 API 내용은 AWS SDK for C++ API참조에서 구독 취소를 참조하십시오.
-
- CLI
-
- AWS CLI
-
주제 구독을 취소하려면
다음
unsubscribe
예제에서는 주제에서 지정된 구독을 삭제합니다.aws sns unsubscribe \ --subscription-arn
arn:aws:sns:us-west-2:0123456789012:my-topic:8a21d249-4329-4871-acc6-7be709c6ea7f
이 명령은 출력을 생성하지 않습니다.
-
자세한 API 내용은 AWS CLI 명령 참조의 구독 취소를
참조하십시오.
-
- Java
-
- SDK자바 2.x의 경우
-
참고
더 많은 내용이 있습니다. GitHub AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.sns.SnsClient; import software.amazon.awssdk.services.sns.model.SnsException; import software.amazon.awssdk.services.sns.model.UnsubscribeRequest; import software.amazon.awssdk.services.sns.model.UnsubscribeResponse; /** * Before running this Java V2 code example, set up your development * environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class Unsubscribe { public static void main(String[] args) { final String usage = """ Usage: <subscriptionArn> Where: subscriptionArn - The ARN of the subscription to delete. """; if (args.length < 1) { System.out.println(usage); System.exit(1); } String subscriptionArn = args[0]; SnsClient snsClient = SnsClient.builder() .region(Region.US_EAST_1) .build(); unSub(snsClient, subscriptionArn); snsClient.close(); } public static void unSub(SnsClient snsClient, String subscriptionArn) { try { UnsubscribeRequest request = UnsubscribeRequest.builder() .subscriptionArn(subscriptionArn) .build(); UnsubscribeResponse result = snsClient.unsubscribe(request); System.out.println("\n\nStatus was " + result.sdkHttpResponse().statusCode() + "\n\nSubscription was removed for " + request.subscriptionArn()); } catch (SnsException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } } }
-
자세한 API 내용은 AWS SDK for Java 2.x API참조에서 구독 취소를 참조하십시오.
-
- JavaScript
-
- SDK JavaScript (v3) 에 대한
-
참고
더 많은 정보가 있습니다. GitHub AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. 별도의 모듈에서 클라이언트를 생성하고 내보냅니다.
import { SNSClient } from "@aws-sdk/client-sns"; // The AWS Region can be provided here using the `region` property. If you leave it blank // the SDK will default to the region set in your AWS config. export const snsClient = new SNSClient({});
SDK및 클라이언트 모듈을 가져와서 호출하십시오API.
import { UnsubscribeCommand } from "@aws-sdk/client-sns"; import { snsClient } from "../libs/snsClient.js"; /** * @param {string} subscriptionArn - The ARN of the subscription to cancel. */ const unsubscribe = async ( subscriptionArn = "arn:aws:sns:us-east-1:xxxxxxxxxxxx:mytopic:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", ) => { const response = await snsClient.send( new UnsubscribeCommand({ SubscriptionArn: subscriptionArn, }), ); console.log(response); // { // '$metadata': { // httpStatusCode: 200, // requestId: '0178259a-9204-507c-b620-78a7570a44c6', // extendedRequestId: undefined, // cfId: undefined, // attempts: 1, // totalRetryDelay: 0 // } // } return response; };
-
자세한 정보는 AWS SDK for JavaScript 개발자 안내서를 참조하십시오.
-
자세한 API 내용은 AWS SDK for JavaScript API참조에서 구독 취소를 참조하십시오.
-
- Kotlin
-
- SDKKotlin의 경우
-
참고
더 많은 정보가 있습니다. GitHub AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. suspend fun unSub(subscriptionArnVal: String) { val request = UnsubscribeRequest { subscriptionArn = subscriptionArnVal } SnsClient { region = "us-east-1" }.use { snsClient -> snsClient.unsubscribe(request) println("Subscription was removed for ${request.subscriptionArn}") } }
-
API자세한 내용은 Kotlin AWS SDK API 참조용 구독 취소를
참조하세요.
-
- PHP
-
- PHP용 SDK
-
참고
자세한 내용은 다음과 같습니다. GitHub AWS 코드 예제 리포지토리
에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요. require 'vendor/autoload.php'; use Aws\Exception\AwsException; use Aws\Sns\SnsClient; /** * Deletes a subscription to 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 */ $SnSclient = new SnsClient([ 'profile' => 'default', 'region' => 'us-east-1', 'version' => '2010-03-31' ]); $subscription = 'arn:aws:sns:us-east-1:111122223333:MySubscription'; try { $result = $SnSclient->unsubscribe([ 'SubscriptionArn' => $subscription, ]); var_dump($result); } catch (AwsException $e) { // output error message if fails error_log($e->getMessage()); }
-
자세한 정보는 AWS SDK for PHP 개발자 안내서를 참조하십시오.
-
자세한 API 내용은 AWS SDK for PHP API참조에서 구독 취소를 참조하십시오.
-
- Python
-
- SDK파이썬용 (보토3)
-
참고
더 많은 정보가 있습니다. GitHub AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. class SnsWrapper: """Encapsulates Amazon SNS topic and subscription functions.""" def __init__(self, sns_resource): """ :param sns_resource: A Boto3 Amazon SNS resource. """ self.sns_resource = sns_resource @staticmethod def delete_subscription(subscription): """ Unsubscribes and deletes a subscription. """ try: subscription.delete() logger.info("Deleted subscription %s.", subscription.arn) except ClientError: logger.exception("Couldn't delete subscription %s.", subscription.arn) raise
-
자세한 API AWS SDK내용은 Python (Boto3) 참조의 구독 취소를 참조하십시오. API
-
- SAP ABAP
-
- SDK에 대한 SAP ABAP
-
참고
더 많은 정보가 있습니다 GitHub. AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. TRY. lo_sns->unsubscribe( iv_subscriptionarn = iv_subscription_arn ). MESSAGE 'Subscription deleted.' TYPE 'I'. CATCH /aws1/cx_snsnotfoundexception. MESSAGE 'Subscription does not exist.' TYPE 'E'. CATCH /aws1/cx_snsinvalidparameterex. MESSAGE 'Subscription with "PendingConfirmation" status cannot be deleted/unsubscribed. Confirm subscription before performing unsubscribe operation.' TYPE 'E'. ENDTRY.
-
API자세한 내용은 AWS SDKSAPABAPAPI참조용 구독 취소를 참조하십시오.
-
주제 삭제
주제 및 모든 구독을 삭제하려면 SNS API Amazon에 ListTopics
요청을 ARN 제출하여 주제를 가져온 다음 DeleteTopic
요청에 전달하십시오. ARN
다음 코드 예제는 DeleteTopic
의 사용 방법을 보여 줍니다.
- .NET
-
- AWS SDK for .NET
-
참고
자세한 내용은 GitHub 다음과 같습니다. AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. 주제별로 주제를 ARN 삭제하세요.
/// <summary> /// Delete a topic by its topic ARN. /// </summary> /// <param name="topicArn">The ARN of the topic.</param> /// <returns>True if successful.</returns> public async Task<bool> DeleteTopicByArn(string topicArn) { var deleteResponse = await _amazonSNSClient.DeleteTopicAsync( new DeleteTopicRequest() { TopicArn = topicArn }); return deleteResponse.HttpStatusCode == HttpStatusCode.OK; }
-
자세한 API 내용은 DeleteTopic AWS SDK for .NETAPI참조를 참조하십시오.
-
- C++
-
- SDKC++의 경우
-
참고
더 많은 정보가 있습니다. GitHub AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. //! Delete an Amazon Simple Notification Service (Amazon SNS) topic. /*! \param topicARN: The Amazon Resource Name (ARN) for an Amazon SNS topic. \param clientConfiguration: AWS client configuration. \return bool: Function succeeded. */ bool AwsDoc::SNS::deleteTopic(const Aws::String &topicARN, const Aws::Client::ClientConfiguration &clientConfiguration) { Aws::SNS::SNSClient snsClient(clientConfiguration); Aws::SNS::Model::DeleteTopicRequest request; request.SetTopicArn(topicARN); const Aws::SNS::Model::DeleteTopicOutcome outcome = snsClient.DeleteTopic(request); if (outcome.IsSuccess()) { std::cout << "Successfully deleted the Amazon SNS topic " << topicARN << std::endl; } else { std::cerr << "Error deleting topic " << topicARN << ":" << outcome.GetError().GetMessage() << std::endl; } return outcome.IsSuccess(); }
-
자세한 API 내용은 DeleteTopic AWS SDK for C++API참조를 참조하십시오.
-
- CLI
-
- AWS CLI
-
SNS주제를 삭제하려면
다음
delete-topic
예제에서는 지정된 SNS 주제를 삭제합니다.aws sns delete-topic \ --topic-arn
"arn:aws:sns:us-west-2:123456789012:my-topic"
이 명령은 출력을 생성하지 않습니다.
-
자세한 API 내용은 AWS CLI 명령 DeleteTopic
참조를 참조하십시오.
-
- Go
-
- SDKGo V2의 경우
-
참고
더 많은 내용이 있습니다 GitHub. AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. // SnsActions encapsulates the Amazon Simple Notification Service (Amazon SNS) actions // used in the examples. type SnsActions struct { SnsClient *sns.Client } // DeleteTopic delete an Amazon SNS topic. func (actor SnsActions) DeleteTopic(topicArn string) error { _, err := actor.SnsClient.DeleteTopic(context.TODO(), &sns.DeleteTopicInput{ TopicArn: aws.String(topicArn)}) if err != nil { log.Printf("Couldn't delete topic %v. Here's why: %v\n", topicArn, err) } return err }
-
자세한 API 내용은 DeleteTopic AWS SDK for Go
API참조를 참조하십시오.
-
- Java
-
- SDK자바 2.x의 경우
-
참고
더 많은 내용이 있습니다. GitHub AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.sns.SnsClient; import software.amazon.awssdk.services.sns.model.DeleteTopicRequest; import software.amazon.awssdk.services.sns.model.DeleteTopicResponse; import software.amazon.awssdk.services.sns.model.SnsException; /** * Before running this Java V2 code example, set up your development * environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class DeleteTopic { public static void main(String[] args) { final String usage = """ Usage: <topicArn> Where: topicArn - The ARN of the topic to delete. """; if (args.length != 1) { System.out.println(usage); System.exit(1); } String topicArn = args[0]; SnsClient snsClient = SnsClient.builder() .region(Region.US_EAST_1) .build(); System.out.println("Deleting a topic with name: " + topicArn); deleteSNSTopic(snsClient, topicArn); snsClient.close(); } public static void deleteSNSTopic(SnsClient snsClient, String topicArn) { try { DeleteTopicRequest request = DeleteTopicRequest.builder() .topicArn(topicArn) .build(); DeleteTopicResponse result = snsClient.deleteTopic(request); System.out.println("\n\nStatus was " + result.sdkHttpResponse().statusCode()); } catch (SnsException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } } }
-
자세한 API 내용은 DeleteTopic AWS SDK for Java 2.xAPI참조를 참조하십시오.
-
- JavaScript
-
- SDK JavaScript (v3) 에 대한
-
참고
더 많은 정보가 있습니다. GitHub AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. 별도의 모듈에서 클라이언트를 생성하고 내보냅니다.
import { SNSClient } from "@aws-sdk/client-sns"; // The AWS Region can be provided here using the `region` property. If you leave it blank // the SDK will default to the region set in your AWS config. export const snsClient = new SNSClient({});
SDK및 클라이언트 모듈을 가져와서 호출하십시오API.
import { DeleteTopicCommand } from "@aws-sdk/client-sns"; import { snsClient } from "../libs/snsClient.js"; /** * @param {string} topicArn - The ARN of the topic to delete. */ export const deleteTopic = async (topicArn = "TOPIC_ARN") => { const response = await snsClient.send( new DeleteTopicCommand({ TopicArn: topicArn }), ); console.log(response); // { // '$metadata': { // httpStatusCode: 200, // requestId: 'a10e2886-5a8f-5114-af36-75bd39498332', // extendedRequestId: undefined, // cfId: undefined, // attempts: 1, // totalRetryDelay: 0 // } // } };
-
자세한 정보는 AWS SDK for JavaScript 개발자 안내서를 참조하십시오.
-
자세한 API 내용은 DeleteTopic AWS SDK for JavaScriptAPI참조를 참조하십시오.
-
- Kotlin
-
- SDK코틀린의 경우
-
참고
더 많은 정보가 있습니다. GitHub AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. suspend fun deleteSNSTopic(topicArnVal: String) { val request = DeleteTopicRequest { topicArn = topicArnVal } SnsClient { region = "us-east-1" }.use { snsClient -> snsClient.deleteTopic(request) println("$topicArnVal was successfully deleted.") } }
-
자세한 API AWS SDK내용은 Kotlin API 참조를 참조하세요 DeleteTopic
.
-
- PHP
-
- PHP용 SDK
-
참고
자세한 내용은 다음과 같습니다. GitHub AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. require 'vendor/autoload.php'; use Aws\Exception\AwsException; use Aws\Sns\SnsClient; /** * Deletes an SNS topic and all its subscriptions. * * 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 */ $SnSclient = new SnsClient([ 'profile' => 'default', 'region' => 'us-east-1', 'version' => '2010-03-31' ]); $topic = 'arn:aws:sns:us-east-1:111122223333:MyTopic'; try { $result = $SnSclient->deleteTopic([ 'TopicArn' => $topic, ]); var_dump($result); } catch (AwsException $e) { // output error message if fails error_log($e->getMessage()); }
-
자세한 API 내용은 DeleteTopic AWS SDK for PHPAPI참조를 참조하십시오.
-
- Python
-
- SDK파이썬용 (보토3)
-
참고
더 많은 정보가 있습니다. GitHub AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. class SnsWrapper: """Encapsulates Amazon SNS topic and subscription functions.""" def __init__(self, sns_resource): """ :param sns_resource: A Boto3 Amazon SNS resource. """ self.sns_resource = sns_resource @staticmethod def delete_topic(topic): """ Deletes a topic. All subscriptions to the topic are also deleted. """ try: topic.delete() logger.info("Deleted topic %s.", topic.arn) except ClientError: logger.exception("Couldn't delete topic %s.", topic.arn) raise
-
자세한 API AWS SDK내용은 Python (Boto3) API 참조를 참조하십시오 DeleteTopic.
-
- SAP ABAP
-
- SDK에 대한 SAP ABAP
-
참고
더 많은 정보가 있습니다 GitHub. AWS 코드 예시 리포지토리
에서 전체 예시를 찾고 설정 및 실행하는 방법을 배워보세요. TRY. lo_sns->deletetopic( iv_topicarn = iv_topic_arn ). MESSAGE 'SNS topic deleted.' TYPE 'I'. CATCH /aws1/cx_snsnotfoundexception. MESSAGE 'Topic does not exist.' TYPE 'E'. ENDTRY.
-
자세한 API 내용은 SAPABAPAPI참조를AWS SDK 위해 DeleteTopicin을 참조하십시오.
-