-1

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

M.D
  • 67
  • 1
  • 2
  • 12

2 Answers2

-1

Everything seems to be working with the server, I have tried:

$client = new SoapClient("http://87.107.121.52/post/send.asmx?wsdl");

    $sendsms_parameters = array(
                    'username' => 'test',
                    'password' => 'test123',
                    'from' => 'test',
                    'to' => 'test',
                    'text' => 'testasdasd',
                    'isflash' => false,
                    );

    exit(var_dump($client->SendSms($sendsms_parameters)));

And I am getting a response:

enter image description here

Here is my simple test:

<?php

class sendSoap{


    public function soapClient(){

        $client = new SoapClient("http://87.107.121.52/post/send.asmx?wsdl");
        return $client;
    }

}


class sendSms{


    public function sendSmsClient(){

        $soapService = new sendSoap;

        $params = [

            'username' => 'test',
            'password' => 'test',
            'from' => 'testuser',
            'to' => 'test users',
            'text' => 'some text',
            'isflash' => false,
        ];

        $response = $soapService->soapClient()->SendSms($params);

        return $response;
    }
}


$smsService = new sendSms;

$response = $smsService->sendSmsClient();

exit(var_dump($response));
Leo
  • 7,274
  • 5
  • 26
  • 48
-1

The error says that you can't import/load the WSDL from the URL given http://87.107.121.52/post/send.asmx?wsdl.

It works for you in the test, that means that you can access to this URL from your test environment but your customer can't do it from his environment.

You have the externalise the value of URL to be customizedby your customer

losusovic
  • 608
  • 5
  • 22