Reputation: 181
I'm using latest PHP SDK(V3) for Amazon SNS. I have a problem when I'm trying to create an endpoint for a platform (Registering user devices to a platform). The error says I have an "InvalidArgumentException", but I have double checked with the document and I'm passing correct arguments. Please find below my code.
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();
}
If anyone can help or point me to right direction it is highly appreciated.
Upvotes: 1
Views: 1480
Reputation: 181
Here is the full answer just in case if anyone interested,
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;
}
Upvotes: 6