I try to send SMS using Soap to my users when I use my SMS class in other classes SMS send currently but in one of my class it doesn't work! My SMS class :
class SendSMS
{
private $client;
private $property;
private $settings;
function __construct()
{
ini_set("soap.wsdl_cache_enabled", "0");
$this->settings = Setting::options();
}
public function _SetClient(){
$this->client = new SoapClient("http://87.107.121.52/post/send.asmx?wsdl");
}
public function _SetSmsProperties(array $property){
$this->property = $property;
}
public function _StartSending()
{
$logs = array();
foreach ($this->property as $sms){
$logs[] = $this->Send($sms['number'],$sms['message'],null,false);
}
file_put_contents(ABSPATH . rand(0001,9999) . '-smslog.txt', implode("\n",$logs) ,FILE_APPEND);
}
public function Send($number, $msg, $sender = null,$service = false)
{
$this->client = new SoapClient("http://87.107.121.52/post/send.asmx?wsdl");
ini_set("soap.wsdl_cache_enabled", "0");
$numbers = array();
if(!is_array($number))
{
$numbers[] = $number;
}
else
{
$numbers = $number;
}
// New Edition
if(!is_null($sender)){
$from = $sender;
}
elseif($service == true){
$from = '50008';
}
else
{
$from = $this->settings['sms_line'];
}
$sendsms_parameters = array(
'username' => $this->settings['sms_username'],
'password' => $this->settings['sms_password'],
'from' => $from,
'to' => $numbers,
'text' => iconv("UTF-8", 'UTF-8//TRANSLIT',$msg),
'isflash' => false,
'udh' => "",
'recId' => array(0),
'status' => 0
);
$status = $this->client->SendSms($sendsms_parameters)->SendSmsResult;
//echo $status;
if($status == 1)
{
return true;
}
return false;
}
And this is my test class to send a simple SMS :
class test{
public function send()
{
$property = array();
$property[] = array(
'number' => 'XXXXXXXX',
'message' => 'Hello User',
);
$sms = new SendSMS();
$sms->_SetClient();
$sms->_SetSmsProperties($property);
var_dump($sms->_StartSending());
}
}
at least when I try to send SMS in my users class it doesn't work and show me this error
[11-Nov-2017 14:30:30 Asia/Tehran] PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://87.107.121.52/post/send.asmx?wsdl' : failed to load external entity "http://87.107.121.52/post/send.asmx?wsdl" in E:\xampp\htdocs\danacrm\libs\SendSMS.php on line 19
[11-Nov-2017 14:30:30 Asia/Tehran] PHP Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://87.107.121.52/post/send.asmx?wsdl' : failed to load external entity "http://87.107.121.52/post/send.asmx?wsdl" in E:\xampp\htdocs\danacrm\libs\SendSMS.php:19