简体   繁体   中英

Amazon SDK for Php SNS Publish Error 500

I am getting an error 500 when trying to do a SNS publish using the Amazon AWS SDK for PHP. If I run PHP sendPush.php in terminal it works perfectly fine but if I go to the URL in chrome I get an error 500.

Here is my PHP file:

<?php
require 'vendor/autoload.php';
use Aws\Credentials\CredentialProvider;
use Aws\Sns\SnsClient;

$arn = "<my arn endpoint here>";
$message = 'test1';

$provider = CredentialProvider::env();

$client = SnsClient::factory(array(
    'profile' => 'default',
    'credentials' => $provider,
    'version'     => 'latest',
    'region'      => 'us-east-1'
));

$message_atr =  array(
        'String' => array(
            'DataType' => 'String',
            'StringValue' => $message
        )
    );

$publish_message = array('TargetArn' => $arn,'Message' => $message,'MessageAttributes'=> $message_atr);

$client->publish($publish_message);


?>

我的 .aws 文件夹位于错误的位置,现在可以使用了。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM