php脚本发送Zabbix的短信
我有PHP脚本将向Zabbix监视系统发送按摩的API,但是它无效,任何人都可以帮助我解决
#!/usr/bin/php
<?php
#$debug= false;
$numbers = $argv[1];
$msg = $argv[2];
#if ( $debug ) file_put_contents("/tmp/smsapi_debug_".date("YmdHis"), serialize($argv));
$param["accname"] = "user"; //
$param["accpass"] = "pass";
$param["msg"] = $msg;
$param["numbers"] = $numbers;
$param["senderid"] = "ID";
$xml_data =
'<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<senderid>.$param["senderid"].</senderid>
<numbers>.$param["numbers"].</numbers>
<accname>.$param["accname"].</accname>
<accpass>.$param["accpass"].</accpass>
<msg>.$param["msg"].</msg>
</soap12:Body>
</soap12:Envelope>';
$url = "API URL";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTP_VERSION,1.1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/soap+xml; charset=utf-8','Content-Length:250'));
curl_setopt($ch, CURLOPT_POSTFIELDS,$xml_data);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
print $response;
if ($httpCode >= 200 && $httpCode < 300) {
}else {
file_put_contents("/tmp/smsapi_error_".date("YmdHis"), curl_error($ch));
die(curl_error($ch)."\n");
}
curl_close($ch);
?>
的错误。
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><soap:Code><soap:Value>soap:Sender</soap:Value></soap:Code><soap:Reason><soap:Text xml:lang="en">Unable to handle request without a valid action parameter. Please supply a valid soap action.</soap:Text></soap:Reason><soap:Detail /></soap:Fault></soap:Body></soap:Envelope>
下面 发送消息
谢谢
I have PHP script that will be sending massage's to API for zabbix monitoring system but it not working any one can help me with the error below
#!/usr/bin/php
<?php
#$debug= false;
$numbers = $argv[1];
$msg = $argv[2];
#if ( $debug ) file_put_contents("/tmp/smsapi_debug_".date("YmdHis"), serialize($argv));
$param["accname"] = "user"; //
$param["accpass"] = "pass";
$param["msg"] = $msg;
$param["numbers"] = $numbers;
$param["senderid"] = "ID";
$xml_data =
'<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<senderid>.$param["senderid"].</senderid>
<numbers>.$param["numbers"].</numbers>
<accname>.$param["accname"].</accname>
<accpass>.$param["accpass"].</accpass>
<msg>.$param["msg"].</msg>
</soap12:Body>
</soap12:Envelope>';
$url = "API URL";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_HTTP_VERSION,1.1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/soap+xml; charset=utf-8','Content-Length:250'));
curl_setopt($ch, CURLOPT_POSTFIELDS,$xml_data);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
print $response;
if ($httpCode >= 200 && $httpCode < 300) {
}else {
file_put_contents("/tmp/smsapi_error_".date("YmdHis"), curl_error($ch));
die(curl_error($ch)."\n");
}
curl_close($ch);
?>
every time I run the code I got the below error
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><soap:Code><soap:Value>soap:Sender</soap:Value></soap:Code><soap:Reason><soap:Text xml:lang="en">Unable to handle request without a valid action parameter. Please supply a valid soap action.</soap:Text></soap:Reason><soap:Detail /></soap:Fault></soap:Body></soap:Envelope>
what is the correct syntax for the code to be able to send messages
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论