如何在请求html上执行代码

时间:2018-07-18 15:01:49

标签: php html webhooks google-assist-api

我需要使用Google Firebase和Google Assistant在Web服务器上获得一些帮助。当我用Google Assistant发出请求时,它会与IFTTT连为一体,并通过webhooks服务进行webhook,但它仅执行php代码并返回html代码。

代码如下:

<?php
$acction = $_GET["acction"];
$mode = $_GET["mode"];

$file = fopen("test.txt", "w");
fwrite($file, $acction . PHP_EOL);
fwrite($file, $mode . PHP_EOL);
fclose($file);

?>

  <html>
    <head>
        <title>Domotica</title>
        <script src="https://www.gstatic.com/firebasejs/5.2.0/firebase.js"> 
        </script>
    </head>
    <script>
      // Initialize Firebasefalse
      var config = {
        apiKey: "",
        authDomain: "",
        databaseURL: "",
        projectId: "",
        storageBucket: "",
        messagingSenderId: ""
      };
      firebase.initializeApp(config);
    </script>
    <script>
      var db = firebase.database().ref('domotica');
      // último estado
     db.on('value', function(data){
       console.log("data: ", data.val());
     });
     db.update({
       <?php echo $acction ?>:<?php echo $mode ?>
     });
    </script>

    <body>
    </body>
   </html>

0 个答案:

没有答案