AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
与 AWS SDK或GetIdentityVerificationAttributes
一起使用 CLI
以下代码示例演示如何使用 GetIdentityVerificationAttributes
。
操作示例是大型程序的代码摘录,必须在上下文中运行。在以下代码示例中,您可以查看此操作的上下文:
- .NET
-
- AWS SDK for .NET
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 /// <summary> /// Get identity verification status for an email. /// </summary> /// <returns>The verification status of the email.</returns> public async Task<VerificationStatus> GetIdentityStatusAsync(string email) { var result = VerificationStatus.TemporaryFailure; try { var response = await _amazonSimpleEmailService.GetIdentityVerificationAttributesAsync( new GetIdentityVerificationAttributesRequest { Identities = new List<string> { email } }); if (response.VerificationAttributes.ContainsKey(email)) result = response.VerificationAttributes[email].VerificationStatus; } catch (Exception ex) { Console.WriteLine("GetIdentityStatusAsync failed with exception: " + ex.Message); } return result; }
-
有关API详细信息,请参阅 “AWS SDK for .NET API参考 GetIdentityVerificationAttributes” 中的。
-
- CLI
-
- AWS CLI
-
获取身份列表的 Amazon SES 验证状态
以下示例使用
get-identity-verification-attributes
命令检索身份列表的 Amazon SES 验证状态:aws ses get-identity-verification-attributes --identities
"user1@example.com"
"user2@example.com"
输出:
{ "VerificationAttributes": { "user1@example.com": { "VerificationStatus": "Success" }, "user2@example.com": { "VerificationStatus": "Pending" } } }
如果调用此命令时,列表包含从未提交验证的身份,则该身份将不会出现在输出中。
有关经过验证的身份的更多信息,请参阅《亚马逊简单电子邮件服务开发者指南》中的 “SES在亚马逊中验证电子邮件地址和域名”。
-
有关API详细信息,请参阅 “GetIdentityVerificationAttributes AWS CLI
命令参考”。
-
- Python
-
- SDK适用于 Python (Boto3)
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 class SesIdentity: """Encapsulates Amazon SES identity functions.""" def __init__(self, ses_client): """ :param ses_client: A Boto3 Amazon SES client. """ self.ses_client = ses_client def get_identity_status(self, identity): """ Gets the status of an identity. This can be used to discover whether an identity has been successfully verified. :param identity: The identity to query. :return: The status of the identity. """ try: response = self.ses_client.get_identity_verification_attributes( Identities=[identity] ) status = response["VerificationAttributes"].get( identity, {"VerificationStatus": "NotFound"} )["VerificationStatus"] logger.info("Got status of %s for %s.", status, identity) except ClientError: logger.exception("Couldn't get status for %s.", identity) raise else: return status
-
有关API详细信息,请参阅GetIdentityVerificationAttributes中的 AWS SDKPython (Boto3) API 参考。
-
- Ruby
-
- SDK对于 Ruby
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 require 'aws-sdk-ses' # v2: require 'aws-sdk' # Create client in us-west-2 region # Replace us-west-2 with the AWS Region you're using for Amazon SES. client = Aws::SES::Client.new(region: 'us-west-2') # Get up to 1000 identities ids = client.list_identities({ identity_type: 'EmailAddress' }) ids.identities.each do |email| attrs = client.get_identity_verification_attributes({ identities: [email] }) status = attrs.verification_attributes[email].verification_status # Display email addresses that have been verified puts email if status == 'Success' end
-
有关API详细信息,请参阅 “AWS SDK for Ruby API参考 GetIdentityVerificationAttributes” 中的。
-