AWS Personalize — eventType 必须是关联数组

AWS Personalize — eventType must be an associative array

文档说 eventType 必须是 string https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-personalize-events-2018-03-22.html#putevents

所以我做到了:

/* @var PersonalizeEventsClient $client */
$client->putEvents([
    'trackingId' => $trackingId,
    'sessionId' => $uniqueId,
    'userId' => '2',
    'eventList' => [
        'itemId' => '1',
        'eventType' => 'click',
        'sentAt' => (string) time(),
    ],
]);

但我收到下一个验证错误:

[eventList][eventType] must be an associative array. Found string(5) "click"
[eventList][sentAt] must be an associative array. Found string(10) "1611590718"

知道它应该如何运作吗?我试过 json_encode['eventType' => ['key' => 'click']],但没用。

嗯,eventList一定是数组的数组。问题已解决:

/* @var PersonalizeEventsClient $client */
$client->putEvents([
    'trackingId' => $trackingId,
    'sessionId' => $uniqueId,
    'userId' => '2',
    'eventList' => [
        [
            'itemId' => '1',
            'eventType' => 'click',
            'sentAt' => (string) time(),
        ],
    ],
]);