Plesk ve laravel kullanıyorum.
$smsCode = rand(100000, 999999);
$res = Helpers::sendsmsSOAP(Helpers::phoneNumber($phone), 'Gymflock, Doğrulama Kodu: ' . $smsCode, $request->ip(), $request->server('HTTP_USER_AGENT'), null, 1);
return $res;
public static function sendsmsSOAP($telefon, $message, $otp = 0)
{
try {
// $telefon = trim(str_replace(' ', '', $telefon));
$message = trim($message);
$username = env('SOAPSMS_USERNAME', null);
$password = env('SOAPSMS_PASSWORD', null);
$usercode = env('SOAPSMS_USERCODE', null);
$accountID = env('SOAPSMS_ACCOUNTID', null);
$originator = env('SOAPSMS_ORIGINATOR', null);
$url = "https://webservice.asistiletisim.com.tr/SmsProxy.asmx?WSDL";
$request_headers = array(
"Content-Type: text/xml; charset=utf-8",
"SOAPAction: https://webservice.asistiletisim.com.tr/SmsProxy/sendSms",
"Accept: text/xml"
);
$xml = '
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="https://webservice.asistiletisim.com.tr/SmsProxy">
<soapenv:Header/>
<soapenv:Body>
<sendSms>
<requestXml>
<![CDATA[
<SendSms>
<Username>' . $username . '</Username>
<Password>' . $password . '</Password>
<UserCode>' . $usercode . '</UserCode>
<AccountId>' . $accountID . '</AccountId>
<Originator>' . $originator . '</Originator>
<SendDate></SendDate>
<ValidityPeriod>60</ValidityPeriod>
<MessageText>' . $message . '</MessageText>
<IsCheckBlackList>1</IsCheckBlackList>
<ReceiverList>
<Receiver>' . $telefon . '</Receiver>
</ReceiverList>
</SendSms>
]]>
</requestXml>
</sendSms>
</soapenv:Body>
</soapenv:Envelope>
';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $request_headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
if (curl_errno($ch)) {
return 999;
} else {
$response = curl_exec($ch);
curl_close($ch);
$xml = str_ireplace(['SOAP-ENV:', 'SOAP:'], '', $response);
$xml = simplexml_load_string($xml);
$xml = json_decode(json_encode($xml), TRUE);
$response_code = $xml["Body"]["sendSmsResponse"]["sendSmsResult"]["ErrorCode"];
return $response_code;
}
} catch (\Exception $e) {
}
return 1;
}