Amazon SNS using PHP SDK - createPlatformEndpoint "InvalidArgumentException" exception

578

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.

240

Answer

Solution:

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;
}

People are also looking for solutions to the problem: Writing Android app in PHP

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.