php - IFTTT : Trying to run a php script using Maker webhooks

标签 php mysql ifttt

美好的一天,

我创建了一个 IFTTT 收据,如果“myfox”警报系统布防,则会在我的 NAS (192.165.x.x) 上执行一个 php 脚本。 php 脚本应该触发我的 mysql 数据库中的存储过程。

以下 PHP 脚本已经通过其他方式进行了测试,我确信它可以工作:

<?php

/*
    php_update_mode_armed.php

    *****************************************************************************************
    * This script updates the value of the components in the table tbl_eedomus_current_mode
    * It calls the stored procedure 'sp_tbl_eedomus_current_mode_armed'
    *****************************************************************************************

    Version 1.00, 09.06.2017, Initial version of the script
*/


mainProcess();

function mainProcess()
{
    $ServerIP = "192.165.x.x";
    $sqlUser = "domoos";
    $sqlDatabase = "domoos";
$pw = "myPass";

    // Connect
    $mysqli = new mysqli($ServerIP, $sqlUser, $pw, $sqlDatabase);
    if(!$mysqli) {[![enter image description here][1]][1]
    header('Location: error.php?error=DbConnectionFailure');
    die();
    }

    // Call stored procedure sp_tbl_eedomus_current_mode_armed 
    if(!$mysqli->query("CALL sp_tbl_eedomus_current_mode_armed ()"))
    {
        echo "OK";
    if($mysqli) $mysqli->close(); // Close DB connection
    //header('Location: error.php?error=QueryFailure');
    die();
    }

    if($mysqli) $mysqli->close(); // Close DB connection    
}


?>

下面还有我的 IFTTT 收据“当时”部分的屏幕截图。

我在这里做错了什么,还是使用 IFTTT 不适合我在这里想要实现的目的?

非常感谢您在此事上的帮助,祝您有美好的一天。

enter image description here

最佳答案

由于家庭路由器防火墙等原因,IFTTT 很可能无法从互联网访问您的 NAS。此外,IFTTT 中使用的 IP 地址不应该是本地 IP 地址(如 192.168.*),而是您的公共(public) IP 地址。你可以通过 googling for "whats my ip 来解决这个问题”。

使用笔记本电脑测试设置的最佳方法是断开与本地 WiFi 网络的连接,将手机连接到笔记本电脑,然后尝试访问 NAS IP URL 以查看它是否仍然有效。您可以使用 Chrome postman 应用发送 POST 请求。

如果一切正常,请让 PHP 通过写入文件来记录传入连接。 file_put_contents("log.txt", print_r($_REQUESTS, true));

我建议首先尝试使用默认内容类型的 GET 请求。祝你好运!

关于php - IFTTT : Trying to run a php script using Maker webhooks,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44451000/

相关文章:

mysql - 仅显示本月没有更新的记录

arduino - 为什么 PIR 传感器在 NodeMCU/ESP8266 板上保持高电平?

php - WordPress 中的 mySQL 查询

PHP fatal error : Call to undefined function password_verify()

php - 网站到 POS 打印机

MySQL 列;在结果集中分成两部分

mysql - Sqoop无法从MYSQL导入数据到HBASE

php - 存储数据的最佳方式

python - 使用树莓派制作启用 ifttt 的家庭自动化系统

android - 如何从 Google Assistant 发出局域网 HTTP 请求?