vasily-kartashov/alexa-skills-kit-model

Amazon Alexa 技能套件模型

1.24.0 2019-11-24 03:54 UTC

This package is auto-updated.

Last update: 2024-09-14 09:30:08 UTC


README

Build Status

这是 Alexa 请求和响应信封与 PHP 类之间的映射。此模型库不进行任何处理,仅负责映射。

读取请求信封

要读取 JSON 请求,请执行

$data = json_decode($payload, true);
$envelope = RequestEnvelope::fromValue($data);

编写响应信封

要创建 JSON 响应,请使用相应的构建器

$speech = PlainTextOutputSpeech::ofText("Plain text string to speak");
    
$response = Response::builder()
    ->withOutputSpeech($speech)
    ->withShouldEndSession(true)
    ->build();
    
$envelope = ResponseEnvelope::builder()
    ->withVersion("string")
    ->withResponse($response)
    ->build();
    
$payload = json_encode($envelope);

Composer

使用 "vasily-kartashov/alexa-skills-kit-model"

待办事项