如何使用PHP SDK向AWS Pinpoint发送调用

时间:2018-02-16 21:17:26

标签: php aws-sdk aws-pinpoint

您好我正在尝试使用AWS Pinpoint和PHP SDK发送消息,但我收到错误消息。有什么想法吗?这是我的代码:

    $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

1 个答案:

答案 0 :(得分:1)

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