-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdi.php
More file actions
40 lines (30 loc) · 1.26 KB
/
di.php
File metadata and controls
40 lines (30 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
$method = $_SERVER['REQUEST_METHOD'];
if($method == 'POST'){
$requestBody = file_get_contents('php://input');
$json = json_decode($requestBody);
$speech = shell_exec("python3 dinnerdata.py");
$response = new \stdClass();
//$response->responseId = $json->responseId;
/*$response->speech = $speech;
$response->displayText = $speech;
$response->source = "diphp-webhook";
/*$response->queryResult->queryText = $text;
$response->queryResult->action = "input.General";
$response->queryResult->parameters = "";
$response->queryResult->allRequiredParamsPresent = true;
$response->queryResult->fulfillmentText = $speech;
$response->queryResult->fulfillmentMessages->text->text = $speech;*/
/*$response->payload->google->expectUserResponse = false;
$response->payload->google->richResponse->items[0]->simpleResponse->textToSpeech = $speech;*/
$response->fulfillmentMessages[0]->text->text[0] = $speech;
$response->payload->google->expectUserResponse = false;
$response->payload->google->richResponse->items[0]->simpleResponse->textToSpeech = $speech;
$r = json_encode($response);
//$r.headers['Content-Type'] = 'application/json';
echo $r;
}
else
{
echo "Method not allowed";
}