使用 PHP 开发工具包的 Amazon SNS - createPlatformEndpoint “InvalidAr


Amazon SNS using PHP SDK - createPlatformEndpoint "InvalidArgumentException" exception

我正在使用最新的 PHP SDK(V3) for Amazon SNS。尝试为平台创建端点(将用户设备注册到平台)时遇到问题。错误说我有一个"无效参数异常",但我仔细检查了文档,并且我传递了正确的参数。请在下面找到我的代码。

try {
  $credentials = new Credentials($SNS_ACCESS_KEY, $SNS_SECRET_KEY);
  $s3Client = new S3Client([
    'version'     => 'latest',
    'region'      => 'us-west-2',
    'credentials' => $credentials
  ]);
  $SNSEndPointData = $s3Client->createPlatformEndpoint([
    'PlatformApplicationArn' => $SNS_APP_ARN,
    'Token' => $device_token
  ]);
}
catch(exception $e) {
   print $e->__toString();
}

如果有人可以帮助或指出我正确的方向,我们将不胜感激。

这是完整的答案,以防万一有人感兴趣,

require 'vendor/autoload.php';
use Aws'Credentials'Credentials;
use Aws'Sns'SnsClient;
try {
    $credentials = new Credentials($SNS_ACCESS_KEY, $SNS_SECRET_KEY);
    $client = new SnsClient([
       'version'     => 'latest',
       'region'      => 'us-west-2',
       'credentials' => $credentials
    ]);

    $SNSEndPointData = $client->createPlatformEndpoint([
       'PlatformApplicationArn' => $SNS_APP_ARN,
       'Token' => 'phone token'
    ]);

     print $SNSEndPointData;
}
catch(exception $e) {
    $message = $e->getMessage();
    print $message;
}