【问题标题】:Send sms to Indian numbers using aws sns使用 aws sns 向印度号码发送短信
【发布时间】:2016-11-29 14:38:31
【问题描述】:

我正在尝试使用 aws sns 使用以下代码向特定号码发送短信,但它需要一个不适用于我的目标/主题 arn,因为我想向我在参数中设置的号码发送短信.

$client = SnsClient::factory([
        'credentials' => [
            'key'    => "my key",
            'secret' => "my secret"
        ],
        'region'  => "us-east-1",
        'version' => "latest"
    ]);

    $sent = $client->publish(
        [

            'Message' => 'This is the message',
            'PhoneNumber' => '+91887******7'
        ]
    );

我无法找到发布对象的确切参数。

【问题讨论】:

    标签: php sms amazon-sns aws-php-sdk


    【解决方案1】:

    我必须更新 aws php sdk (1)。然后下面的代码可以正常工作-

    $sns = SnsClient::factory(array(
            'credentials' => array(
                'key' => 's3_key',
                'secret' => 's3_secret'
            ),
            'region' => Constants::$s3Region,
            'version' => 'latest'
        ));
    
    $msgattributes = [
            'AWS.SNS.SMS.SenderID' => [
                'DataType' => 'String',
                'StringValue' => 'Klassroom',
            ],
            'AWS.SNS.SMS.SMSType' => [
                'DataType' => 'String',
                'StringValue' => 'Transactional',
            ]
        ];
    
        $payload = array(
            'Message' => $message,
            'PhoneNumber' => $number,
            'MessageAttributes' => $msgattributes
        );
    
        $result=$sns->publish($payload);
    

    【讨论】:

      【解决方案2】:

      来自Amazon SNS Publish() documentation for PHP

      • TargetArn:如果不为TargetArn 参数指定值,则必须为PhoneNumberTopicArn 参数指定值。
      • TopicArn:如果不为TopicArn 参数指定值,则必须为PhoneNumberTargetArn 参数指定值。
      • PhoneNumber:如果不为PhoneNumber 参数指定值,则必须为TargetArnTopicArn 参数指定值。

      因此,请提供 PhoneNumber 而不是目标/主题。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-04-06
        • 1970-01-01
        • 1970-01-01
        • 2017-04-11
        • 1970-01-01
        • 2022-01-17
        相关资源
        最近更新 更多