| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace common\components;
- use common\helpers\LoggerTool;
- use common\models\Countries;
- use common\models\SmsRecord;
- use ElkenGit\EknotifierPHP\EknotifierSms;
- class EknotifierSmsDriver implements SmsDriverInterface
- {
- /**
- * Send SMS via Eknotifier.
- *
- * @param string $mobile
- * @param string $message
- * @param string $userId
- * @param string $countryId
- * @param string $classify
- * @return bool
- * @throws \Exception
- */
- public function send(string $mobile, string $message, string $userId, string $countryId, string $classify = ''): bool
- {
- $eknotifierUrl = \Yii::$app->params['sms']['url'];
- $applicationCode = \Yii::$app->params['sms']['url'];
- $applicationPassword = \Yii::$app->params['sms']['url'];
- $zoneCode = Countries::getZoneCodeById($countryId);
- $eknotifierSms = new EknotifierSms($eknotifierUrl, $applicationCode, $applicationPassword);
- $response = $eknotifierSms->sendSMS($mobile, $message, $userId);
- LoggerTool::debug(['eknotifierSms', $eknotifierUrl, $applicationCode, $applicationPassword, $mobile, $zoneCode, $message, $userId, $eknotifierSms, $response]);
- $record = new SmsRecord();
- $record->USER_ID = $userId;
- $record->CLASSIFY = $classify;
- $record->COUNTRY_ID = $countryId;
- $record->MOBILE = $mobile;
- $record->ZONE_CODE = $zoneCode;
- $record->CONTENT = $message;
- $record->RESULT = '';
- $record->save();
- return true;
- }
- }
|