You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<?php
namespace App\Service\v3\Implementations;
use AlibabaCloud\Client\AlibabaCloud;use AlibabaCloud\Client\Exception\ClientException;use AlibabaCloud\Client\Exception\ServerException;use App\Constants\v3\ErrorCode;use App\Exception\ErrorCodeException;use Exception;use App\Commons\Log;use App\Constants\v3\SmsTemplateCode;use Hyperf\Di\Annotation\Inject;use App\Service\v3\Interfaces\SmsSendServiceInterface;
class SmsAliSendService implements SmsSendServiceInterface{
/** * @Inject * @var Log */ protected $log;
public function do($tel, $template, $templateParams) {
try { $aliSms = config('alisms'); AlibabaCloud::accessKeyClient($aliSms['app_key'], $aliSms['app_secret']) ->regionId($aliSms['regionid']) ->asDefaultClient();
$result = AlibabaCloud::rpc() ->product($aliSms['product']) ->version('2017-05-25') ->action('SendSms') ->method('POST') ->host($aliSms['host']) ->options([ 'query' => [ 'RegionId' => $aliSms['regionid'], 'PhoneNumbers' => $tel, 'SignName' => $aliSms['sign_name'], 'TemplateCode' => $template, 'TemplateParam' => $templateParams, ], ]) ->request(); return $result->toArray(); } catch (ClientException $e) { $this->log->event('alisms', ['alisms_error_ClientException' => $e->getErrorMessage()]); throw new ErrorCodeException(ErrorCode::SMS_SEND_FAILURE); } catch (ServerException $e) { $this->log->event('alisms', ['alisms_error_ServerException' => $e->getErrorMessage()]); throw new ErrorCodeException(ErrorCode::SMS_SEND_FAILURE); } catch (Exception $e) { $this->log->event('alisms', ['alisms_error_Exception' => $e->getErrorMessage()]); throw new ErrorCodeException(ErrorCode::SMS_SEND_FAILURE); } }
public function check() { // TODO: Implement check() method.
}
public function undo() { // TODO: Implement undo() method.
} public function doVerifyCode($tel, $code) { $params = ['user_name' => '疯狂的水叔叔', 'market_name' => '验证码', 'money' => $code]; return $this->do($tel, SmsTemplateCode::ALI_VERIFY_CODE, json_encode($params)); }
public function checkVerifyCode($tel, $code) { // TODO: Implement checkVerifyCode() method.
}
public function undoVerifyCode($tel, $code) { // TODO: Implement removeVerifyCode() method.
}
}
|