im trying to make notification service in laravel...
in config/services.php
I added this array:
'sms-panel' => [
'Username' =>env('SMS_USER_NAME'),
'Password' =>env('SMS_PASSWORD'),
'fromNum' =>env('SMS_NUM'),
'Type' => 0,
'uri'=>env('SMS_API_LINK'),
],
and in .env
file added this:
SMS_USER_NAME=username
SMS_PASSWORD=password
SMS_NUM="+985000xxx"
SMS_API_LINK=http://mydomain.ir/webservice/url/send.php?wsdl
and created Services/Notification.php
class and have a method named sendSms in it :
class Notification
{
public function sendSms(User $user, string $text)
{
//$soap=new SoapClient("http://mydomain.ir/webservice/send.php?wsdl");//insert directly
$url=config('services.sms-panel.uri');
$soap=new SoapClient($url);
$soap->Username = config('services.sms-panel.Username');
$soap->Password = config('services.sms-panel.Password');
$soap->fromNum = config('services.sms-panel.fromNum');
$soap->toNum = array($user->phone_number);
$soap->Content = $text;
$soap->Type = '0';
$array = $soap->SendSMS($soap->fromNum, $soap->toNum, $soap->Content, $soap->Type, $soap->Username, $soap->Password);
var_dump($array);
}
}
and when I try to create new SoapClient
and get URI from config getting this error:
SoapFault SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://mydomain.ir/webservice/url/send.php?wsdl' : Start tag expected, '<' not found
but when directly paste the link(commented line) it works perfectly.
and this is the result of dd($url)
or dd(cconfig('services.sms-panel.uri'))
:
"http://mydomain.ir/webservice/url/send.php?wsdl"