Last active
November 2, 2018 13:43
-
-
Save thomasvt1/122bf561addfdcf9a1f1993606f90ba9 to your computer and use it in GitHub Desktop.
This file contains 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 | |
/** | |
* Processes the message requested | |
* | |
* @param $update | |
*/ | |
function processMessage($update) | |
switch ($update["queryResult"]["action"]) { | |
case "test.hook"; | |
sendMessage(array( | |
"fulfillmentMessages" => array([ | |
"platform" => "ACTIONS_ON_GOOGLE", | |
"simpleResponses" => array("simpleResponses" => [array( | |
"textToSpeech" => "Api request has been solved", | |
"displayText" => "Api request has been solved" | |
)])] | |
))); | |
} | |
} | |
/** | |
* Encodes the parameters given, and echoes them | |
* | |
* @param $parameters | |
*/ | |
function sendMessage($parameters) | |
{ | |
echo json_encode($parameters); | |
} | |
// Things starts here | |
$update_response = file_get_contents("php://input"); | |
$update = json_decode($update_response, true); | |
// Open debug file, to write the request to | |
$myFile = fopen("debug.txt", "w") or die("Unable to open file!"); | |
ob_start(); | |
var_dump($update_response); | |
$result = ob_get_clean(); | |
fwrite($myFile, $result); | |
fclose($myFile); | |
if (isset($update["queryResult"]["action"])) { | |
processMessage($update); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment