Stack Overflow Asked on November 20, 2021
i was used the sms API in my Bluehost hosting. when i was run the code it shown like
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://smeapps.mobitel.lk:8585/EnterpriseSMSV3/EnterpriseSMSWS?wsdl' : failed to load external entity "http://smeapps.mobitel.lk:8585/EnterpriseSMSV3/EnterpriseSMSWS?wsdl" in /storage/ssd4/825/11729825/public_html/sms/sms_backend.php:58 Stack trace: #0 /storage/ssd4/825/11729825/public_html/sms/sms_backend.php(58): SoapClient->SoapClient('http://smeapps....') #1 /storage/ssd4/825/11729825/public_html/sms/sms_backend.php(101): getClient() #2 /storage/ssd4/825/11729825/public_html/sms/sms_backend.php(27): createSession('', 'esyyyyy', 'xxxx', '') #3 {main} thrown in /storage/ssd4/825/11729825/public_html/sms/sms_backend.php on line 58
here this is my code
<?php
$username = $_REQUEST['username'];
$password = $_REQUEST['password'];
//$alias = $_REQUEST['alias'];
$message = $_REQUEST['message'];
$number = $_REQUEST['numbers'];
$session=createSession('',$username,$password,'');
sendMessages($session,'XXXX',$message,$number,0); // 1 for promotional messages, 0 for normal message
closeSession($session);
$session=createSession('',$username,$password,'');
getMessagesFromShortCode($session,"shortcode");
getMessagesFromLongNumber($session,"longnum");
closeSession($session);
//create soap client
function getClient()
{
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient("http://smeapps.mobitel.lk:8585/EnterpriseSMSV3/EnterpriseSMSWS?wsdl");
return $client;
}
//serviceTest
function serviceTest($id,$username,$password,$customer)
{
$client = getClient();
$user = new stdClass();
$user->id = '';
$user->username = $username;
$user->password = $password;
$user->customer = '';
$serviceTest = new stdClass();
$serviceTest->arg0 = $user;
return $client->serviceTest($serviceTest);
}
//create session
function createSession($id,$username,$password,$customer)
{
$client = getClient();
$user = new stdClass();
$user->id = $id;
$user->username = $username;
$user->password = $password;
$user->customer = $customer;
$createSession = new stdClass();
$createSession->user = $user;
$createSessionResponse = new stdClass();
$createSessionResponse = $client->createSession($createSession);
return $createSessionResponse->return;
}
//check if session is valid
function isSession($session)
{
$client = getClient();
$isSession = new stdClass();
$isSession->session = $session;
$isSessionResponse = new stdClass();
$isSessionResponse = $client->isSession($isSession);
return $isSessionResponse->return;
}
//send SMS to recipients
function sendMessages($session,$alias,$message,$recipients,$messageType)
{
$client=getClient();
$smsMessage= new stdClass();
$smsMessage->message=$message;
$smsMessage->messageId="";
$smsMessage->recipients=$recipients;
$smsMessage->retries="";
$smsMessage->sender=$alias;
$smsMessage->messageType=$messageType;
$smsMessage->sequenceNum="";
$smsMessage->status="";
$smsMessage->time="";
$smsMessage->type="";
$smsMessage->user="";
$sendMessages = new stdClass();
$sendMessages->session = $session;
$sendMessages->smsMessage = $smsMessage;
$sendMessagesResponse = new stdClass();
$sendMessagesResponse = $client->sendMessages($sendMessages);
return $sendMessagesResponse->return;
}
//send Unicoded SMS to recipients
function sendMessagesMultiLang($session,$alias,$message,$recipients,$messageType)
{
$client=getClient();
$smsMessageMultiLang = new stdClass();
$smsMessageMultiLang->message=$message;
$smsMessageMultiLang->messageId="";
$smsMessageMultiLang->recipients=$recipients;
$smsMessageMultiLang->retries="";
$smsMessageMultiLang->sender=$alias;
$smsMessageMultiLang->messageType=$messageType;
$smsMessageMultiLang->sequenceNum="";
$smsMessageMultiLang->status="";
$smsMessageMultiLang->time="";
$smsMessageMultiLang->type="";
$smsMessageMultiLang->user="";
$sendMessagesMultiLang = new stdClass();
$sendMessagesMultiLang->session = $session;
$sendMessagesMultiLang->smsMessageMultiLang = $smsMessageMultiLang;
$sendMessagesMultiLangResponse = new stdClass();
$sendMessagesMultiLangResponse = $client->sendMessagesMultiLang($sendMessagesMultiLang);
return $sendMessagesMultiLangResponse->return;
}
//send Campaign SMS to recipients
function sendCampaignMessages($session,$alias,$message,$recipients,$datetime,$multilanguage,$messageType)
{
$client=getClient();
$smsCampaignMessage = new stdClass();
$smsCampaignMessage->message = $message;
$smsCampaignMessage->messageId = "";
$smsCampaignMessage->recipients = $recipients;
$smsCampaignMessage->retries = "";
$smsCampaignMessage->sender = $alias;
$smsCampaignMessage->messageType=$messageType;
$smsCampaignMessage->sequenceNum = "";
$smsCampaignMessage->status = "";
$smsCampaignMessage->time = $datetime;
$smsCampaignMessage->type = "";
$smsCampaignMessage->user = "";
$smsCampaignMessage->esmClass = $multilanguage;
$sendCampaignMessages=new stdClass();
$sendCampaignMessages->session=$session;
$sendCampaignMessages->smsCampaignMessage=$smsCampaignMessage;
$sendCampaignMessagesResponse = new stdClass();
$sendCampaignMessagesResponse = $client->sendCampaignMessages($sendCampaignMessages);
return $sendCampaignMessagesResponse->return;
}
//renew session
function renewSession($session)
{
$client = getClient();
$renewSession = new stdClass();
$renewSession->session = $session;
$renewSessionResponse = new stdClass();
$renewSessionResponse = $client->renewSession($renewSession);
return $renewSessionResponse->return;
}
//close session
function closeSession($session)
{
$client = getClient();
$closeSession = new stdClass();
$closeSession->session = $session;
$client->closeSession($closeSession);
}
//retrieve messages from shortcode
function getMessagesFromShortCode($session,$shortCode)
{
$client = getClient();
$getMessagesFromShortCode = new stdClass();
$getMessagesFromShortCode->session = $session;
$getMessagesFromShortCode->shortcode = $shortCode;
$getMessagesFromShortcodeResponse = new stdClass();
$getMessagesFromShortcodeResponse->return = "";
$getMessagesFromShortcodeResponse = $client->getMessagesFromShortcode($getMessagesFromShortCode);
if(property_exists($getMessagesFromShortcodeResponse,'return'))
return $getMessagesFromShortcodeResponse->return;
else return NULL;
}
//retrieve delivery report
function getDeliveryReports($session,$alias)
{
$client = getClient();
$getDeliveryReports = new stdClass();
$getDeliveryReports->session = $session;
$getDeliveryReports->alias = $alias;
$getDeliveryReportsResponse = new stdClass();
$getDeliveryReportsResponse->return = "";
$getDeliveryReportsResponse = $client->getDeliveryReports($getDeliveryReports);
if(property_exists($getDeliveryReportsResponse,'return'))
return $getDeliveryReportsResponse->return;
else return NULL;
}
//retrieve messages from longnumber
function getMessagesFromLongNumber($session,$longNumber)
{
$client = getClient();
$getMessagesFromLongNumber = new stdClass();
$getMessagesFromLongNumber->session = $session;
$getMessagesFromLongNumber->longNumber=$longNumber;
$getMessagesFromLongNumberResponse = new stdClass();
$getmessagesFromLongNumberResponse->return = "";
$getMessagesFromLongNumberResponse = $client->getMessagesFromLongNumber($getMessagesFromLongNumber);
if(property_exists($getMessagesFromLongNumberResponse,'return'))
return $getMessagesFromLongNumberResponse->return;
else return NULL;
}
?>
this code works in Localhost very well… but in my hosting (Bluehost) it was shown fatal error like that.
can any one help me to resolve this error??
Thanks in advance
It turns out that you need to have the extension php_openssl
enabled on your server for it to work.
You can do this yourself on most hosting services by going to your PHP settings -> look for the option php_openssl.dll
or php_openssl
and enable it.
If you have access to your php.ini
file, you could look for the line that says extension=php_openssl.dll
and if this has a ;
at the start like this ;extension=php_openssl.dll
, remove the ;
from the start so it reads extension=php_openssl.dll
.
This should solve it for you.
Answered by mw509 on November 20, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP