0

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

Jan Garaj
  • 25,598
  • 3
  • 38
  • 59
  • Please trim your code to make it easier to find your problem. Follow these guidelines to create a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example). – Community May 09 '22 at 19:37
  • there's no `` in your code, see https://stackoverflow.com/questions/7120586/soap-request-in-php-with-curl – Iron Bishop May 11 '22 at 09:15

0 Answers0