飞信机器人的网页接口

# vim /var/www/html/fetion.php

<?php
header("content-type:text/plain; charset=UTF-8");
$command = "/usr/local/nagios/libexec/duanxin.sh";
$params = array("phone","msg");
//var_dump($params);
foreach ($params as $param) {
                if(isset($_REQUEST[$param]) && !empty($_REQUEST[$param])) {
                        $val = "\"".$_REQUEST[$param]."\"";
                        $command = $command." ".$val;
                } else {
                        die('Params error. your should do like this ?phone=xxx&msg=xxx');
                }
}
//var_dump($command);
//`$command &>/tmp/err.txt`;
system($command);
?>

# vim /usr/local/nagios/libexec/duanxin.sh


#!/bin/bash
/usr/local/fetion2/fetion --mobile=手机号码 --pwd=飞信密码 --to="$1" --msg-utf8="$2"
注意:$1是接口的第一个参数,$2是接口的第二个参数。


你可能感兴趣的:(Fetion)