如何使用 PHP SDK 使用 AWS Pinpoint 服务发送消息

How to send messages using AWS Pinpoint service using PHP SDK

您好,我正在尝试使用带有 PHP SDK 的 AWS Pinpoint 发送消息,但出现错误。任何想法为什么?这是我的代码:

    $client = new PinpointClient([
        'version' => 'latest',
        'region'  => 'us-east-1',
        'credentials' => [
            'key'    => 'MYIAMAWSKEY',
            'secret' => 'MYAWSSECRET',
        ]
    ]);

    $result = $client->sendMessages([
        'ApplicationId' => 'MyAppId',
        'MessageRequest' => [
            'Addresses' => [
               'AnIOSDeviceToken' => [
                    'BodyOverride' => 'aaa',
                    'ChannelType' => 'APNS',
                    'RawContent' => 'bbb',
                    'Context' => ['ccc' => '222'],
                    'TitleOverride' => 'ddd',
                ],
            ],
        ],
        'MessageConfiguration' => [
            'APNSMessage' => [
                    'Action' => 'OPEN_APP',
                    'Body' => 'Hello',
                    'RawContent' => 'World',
                    'SilentPush' => false,
                    'Title' => 'Hello World!!!',
                ],
        ],
    ]);

我收到以下错误:

DeliveryStatus: 'PERMANENT_FAILURE'
StatusCode: 400
StatusMessage: Invalid notification: Notification is malformed

根据 the API Docs'MessageConfiguration' 需要在 'MessageRequest' 字段内。请确保您的输入参数与记录的 API 参数语法完全匹配。