0

文档说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']],但它不起作用。

4

1 回答 1

0

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

/* @var PersonalizeEventsClient $client */
$client->putEvents([
    'trackingId' => $trackingId,
    'sessionId' => $uniqueId,
    'userId' => '2',
    'eventList' => [
        [
            'itemId' => '1',
            'eventType' => 'click',
            'sentAt' => (string) time(),
        ],
    ],
]);
于 2021-01-25T16:55:44.583 回答