PHP - Amazon AWS SES - 如何验证域名的状态

时间:2013-06-11 16:12:10

标签: php amazon-web-services

我在“已验证的域名”列表中添加了一个新域名,更新了DNS,现在我想通过API(实际是PHP SDK)验证域名是否已被aws标记为已验证。到目前为止我有这个

function get_verified_status($domain, $key, $secret) {
// Instantiate the client with your AWS credentials
        $ses = SesClient::factory(array(
                    'key'     => $key,
                    'secret'  => $secret,
                    'region'  => Region::US_EAST_1
                ));
print_r($domain);
echo "response";
$response = $ses->GetIdentityVerificationAttributes($domain);
#$response = $ses->list_verified_email_addresses();

//get_identity_verification_attributes
        return $response;
}

响应是(从cli运行)

php test.php

Array
(
    [0] => appi.com
    [1] => acs.com
)
responsePHP Fatal error:  Uncaught exception 'Guzzle\Service\Exception\ValidationException' with message 'Validation errors: [Identities] is a required array: A list of identities.' in /var/www/html/s3/vendor/guzzle/guzzle/src/Guzzle/Service/Command/AbstractCommand.php:376
Stack trace:
#0 /var/www/html/s3/vendor/guzzle/guzzle/src/Guzzle/Service/Command/AbstractCommand.php(272): Guzzle\Service\Command\AbstractCommand->validate()
#1 /var/www/html/s3/vendor/guzzle/guzzle/src/Guzzle/Service/Client.php(193): Guzzle\Service\Command\AbstractCommand->prepare()
#2 /var/www/html/s3/vendor/guzzle/guzzle/src/Guzzle/Service/Command/AbstractCommand.php(162): Guzzle\Service\Client->execute(Object(Aws\Common\Command\QueryCommand))
#3 /var/www/html/s3/vendor/guzzle/guzzle/src/Guzzle/Service/Command/AbstractCommand.php(213): Guzzle\Service\Command\AbstractCommand->execute()
#4 /var/www/html/s3/vendor/guzzle/guzzle/src/Guzzle/Service/Client.php(93): Guzzle\Service\Command\AbstractCommand->getResult()
#5 /var/www/html/s3/vendo in /var/www/html/s3/vendor/guzzle/guzzle/src/Guzzle/Service/Command/AbstractCommand.php on line 376

我不明白为什么我会收到此错误,因为我传递的数组在print中可以看到。我非常感谢你的帮助

1 个答案:

答案 0 :(得分:2)

根据AWS SDK for PHP API docs for GetIdentityVerificationAttributes,输入参数的结构表明你应该调用这样的方法:

$result = $ses->getIdentityVerificationAttributes(array(
    'Identities' => $domains
));

print_r($result->toArray());

希望有所帮助!