/
var
/
www
/
doncode.com.ua
/
www
/
webhooks
/
/var/www/doncode.com.ua/www/webhooks
mkdir
upload
Name
Size
Mode
Actions
newfile.txt
24
0666
edit
dl
rm
webhook.php
2745
0644
edit
dl
rm
Edit:
/var/www/doncode.com.ua/www/webhooks/webhook.php
(2745B)
<?php function processMessage($update) { if($update["queryResult"]["action"] == "sayHello"){ sendMessage(array( "source" => $update["responseId"], "fulfillmentText"=>"Hello from webhook", "payload" => array( "items"=>[ array( "simpleResponse"=> array( "textToSpeech"=>"response from host" ) ) ], ), )); }else if($update["queryResult"]["action"] == "convert"){ if($update["queryResult"]["parameters"]["outputcurrency"] == "USD"){ $amount = intval($update["queryResult"]["parameters"]["amountToConverte"]["amount"]); $convertresult = $amount * 360; } sendMessage(array( "source" => $update["responseId"], "fulfillmentText"=>"The conversion result is".$convertresult, "payload" => array( "items"=>[ array( "simpleResponse"=> array( "textToSpeech"=>"The conversion result is".$convertresult ) ) ], ), )); }else{ sendMessage(array( "source" => $update["responseId"], "fulfillmentText"=>"Error", "payload" => array( "items"=>[ array( "simpleResponse"=> array( "textToSpeech"=>"Bad request" ) ) ], ), )); } } function sendMessage($parameters) { echo json_encode($parameters); } $update_response = file_get_contents("php://input"); $update = json_decode($update_response, true); if (isset($update["queryResult"]["action"])) { processMessage($update); $myfile = fopen("newfile.txt", "w") or die("Unable to open file!"); fwrite($myfile, $update["queryResult"]["action"]); fclose($myfile); }else{ file_put_contents("newfile.txt","RX ".$_SERVER['REMOTE_ADDR']."\n",FILE_APPEND); sendMessage(array( "source" => $update["responseId"], "fulfillmentText"=>"Hello from webhook", "payload" => array( "items"=>[ array( "simpleResponse"=> array( "textToSpeech"=>"Bad request" ) ) ], ), )); } ?>
Save
cmd:
run