在以下由未知第三方编写的脚本中,我所做的唯一更改是将 $to、$from 和 $body 的值从硬编码字符串更改为 $_GET 元素。该项目的目的是在查询字符串中将一些参数传递给该脚本,然后用它编写和发送短信。
<?php
/**** **** **** **** **** **** **** **** **** **** ****
* sms.php
*
* sample PHP code to send an SMS message to a registered
* extension on a FreeBX 12 server
*
* version history
* 2015-09-22 version 0 by lgaetz@sangoma.com
**** **** **** **** **** **** **** **** **** **** ****/
// Load the FreeBPX bootstrap, requires FreePBX 12
if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) {
include_once('/etc/asterisk/freepbx.conf');
}
// The Asterisk Manager Class from the boostrap is $astman
// If using FreePBX 13+ must set asman with
// $astman = new AGI_AsteriskManager( );
if ($astman) {
// $to = "sip:#######";
// $from = '"Caller ID Name" <#######>';
// $body = "cats are yummy";
$to = $_GET['to'];
$from = $_GET['from'];
$body = $_GET['body'];
$result = $astman->MessageSend($to, $from, $body);
print_r($result); //debug
// the variable $result will be an array of the formats
// Array ( [Response] => Success [Message] => Message successfully sent )
// Array ( [Response] => Error [Message] => Message failed to send. )
} else {
echo "No Asterisk Manager Connection";
}
但是,即使此脚本适用于那些注释掉的硬编码值,将这些值更改为 $_GET 元素也会导致以下错误消息:
Array ( [Response] => Error [Message] => Message technology not found. )
我正在尝试找到某种文档来向我解释它是如何工作的……其他任何使用 FreePBX 引导程序的人有什么想法吗?