Created
March 1, 2020 14:45
-
-
Save giovanemachado/11d3444053eb8b407279c4597cf9cc1f to your computer and use it in GitHub Desktop.
Código utilizado no tutorial 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// A requisição traz conteúdo em JSON, então nós transformamos em um belo array utilizável | |
$arrContent = json_decode(file_get_contents("php://input"), TRUE); | |
// Se você der uma olhada completa no $arrContent, verá que há muitas informações úteis. Pegaremos agora o tipo da requisição. | |
$strRequestType = $arrContent["request"]["type"]; | |
switch ($strRequestType) { | |
case "LaunchRequest": | |
$arrResponse = [ | |
"version" => "1.0", | |
"response" => [ | |
"outputSpeech" => [ | |
"type" => "PlainText", | |
"text" => "Olá, bem vindo ao nosso tutorial. Você pode me dizer seu nome?" | |
], | |
"shouldEndSession" => false | |
] | |
]; | |
break; | |
} | |
// Prepara e responde a requisição, no formato exigido pela Amazon | |
header('Content-Type: application/json;charset=UTF-8'); | |
echo json_encode($arrResponse); | |
die(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment