
ショコラ
AWSのSNSを使うには?
お手頃なのは、pharを使うところでしょうか、

もっさん先輩
aws.phar をダウンロードしました。
curl -LO https://docs.aws.amazon.com/aws-sdk-php/v3/download/aws.phar
aws でユーザーを作り、AmazonSNSFullAcces のポリシーを割り当てました。

credentials ファイルを作成します。
[default]
aws_access_key_id = [アクセスキー]
aws_secret_access_key = [シークレットアクセスキー]
credentials ファイルを作成します。
<?php
require './aws.phar';
use Aws\Sns\SnsClient;
use Aws\Exception\AwsException;
$SnSclient = new SnsClient([
'profile' => 'default',
'region' => 'ap-northeast-1',
'version' => '2010-03-31'
]);
$message = "ワンタイムパスワードはこちらです。\n123456";
$phone = '+818012345678';
try {
$result = $SnSclient->publish([
'Message' => $message,
'PhoneNumber' => $phone,
]);
var_dump($result);
} catch (AwsException $e) {
// output error message if fails
error_log($e->getMessage());
}
以上