我如何根据短信说的话拨打短信并拨打电话提醒某人? [英] How do I take an SMS and make a call to alert someone based on what SMS says?

查看:170
本文介绍了我如何根据短信说的话拨打短信并拨打电话提醒某人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我尝试接收短信,并根据短信所说的内容与特定录音进行通话。

So I am trying to take an incoming SMS and based on what the SMS says make a call with a specific recording.

例如:

我有一个带有调制解调器的门传感器,可以在门打开或门关闭时向我的twilio发送文本。

I have a door sensor with a modem that can send a text to my twilio # when the door is open or when the door is closed.

如果Twilio收到门打开文字,那么twilio将拨打我的手机并播放门打开的录音

If Twilio receives "door open" text then twilio will call my cell phone and plays recording that says "door is open"

如果Twilio收到门关闭 文本然后twilio将拨打我的手机并播放说门已关闭的录音

If Twilio receives "door closed" text then twilio will call my cell phone and plays recording that says "door is closed"

<?php
    require_once('/home/protranx/public_html/twilio-php-      latest/Services/Twilio.php');


    $sid = "SID";
    $token = "Token";
    $client = new Services_Twilio($sid, $token);
    $alert = $_REQUEST['body'];

    $TwilioNumber = "+twilio #";
    $to = "+my cell #";
    $url1 = "http://protran.x10.mx/Oak1_armed_door_open.php";
    $url2 = "http://protran.x10.mx/Oak1_disarmed_door_closed.php";

    $string1 = "door open";
    $string2 = "door closed"; 

    if ($alert == $string1){
        $call = $client->account->calls->create($TwilioNumber, $to, $url1);}


    elseif ($alert == $string2){
        $call = $client->account->calls->create($TwilioNumber, $to, $url2);}
echo $call->sid;


header('content-type: text/xml');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<Response>
</Response>

我一直收到此错误:
错误:12100 - 文档解析失败

I keep getting this error: Error: 12100 - Document parse failure

非常感谢任何帮助。

谢谢

推荐答案

Twilio福音传教士在这里。

Twilio evangelist here.

很难从你的代码中看出来,因为它通常看起来是正确的。

Hard to tell from your code, as it generally looks right.

偶尔让我失望的一件事是在xml开始之前或者在xml声明和根元素之间渲染的空间,所以你可能会检查那些因为那些很难捕获的空间。

One thing that occasionally trips me up is spaces being rendered before the start of the xml or between the xml declaration and the root element, so you might check for either of those that since those can be hard to catch.

例如,我不确定你需要xml声明结尾处的换行符。

For example, I'm not sure you need the newline that you have at the end of your xml declaration.

希望有所帮助。

这篇关于我如何根据短信说的话拨打短信并拨打电话提醒某人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆