From 24a3b0dc6430fd93c6bbdc5006be26c72ebc169b Mon Sep 17 00:00:00 2001 From: lanzu_qinsheng <334039090@qq.com> Date: Tue, 15 Sep 2020 16:56:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=9F=AD=E4=BF=A1=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Common/Rpc.php | 23 +++++++++++++++++++++++ app/Admin/Common/Sms.php | 40 ++-------------------------------------- 2 files changed, 25 insertions(+), 38 deletions(-) diff --git a/app/Admin/Common/Rpc.php b/app/Admin/Common/Rpc.php index 235a302..d980c3d 100644 --- a/app/Admin/Common/Rpc.php +++ b/app/Admin/Common/Rpc.php @@ -14,6 +14,7 @@ class Rpc const ORDER_SINGLE_REFUND = "/order/onlineSingleRefund"; const GET_DISTANCE = "/location/getDistanceByTencent"; const DO_BY_ORDER = "/badge/doByOrder"; + const ALI_SMS_SENT = "/alisms/sent"; @@ -112,5 +113,27 @@ class Rpc return json_decode($response->getBody()->getContents(),true); } + /** + * 阿里大于 + * @param $phone + * @param $template + * @param $templateParams + * @param string $signName + * @return string + */ + public static function alisSmsSent($phone, $template, $templateParams, $signName='懒族生活'){ + $client = Client::factory(env('RPC_SITE_HOST')); + $request = $client->request(uniqid(), + self::ALI_SMS_SENT, + [ + 'phone' => $phone, + 'template'=>$template, + 'templateParams'=> json_encode($templateParams), + 'signName'=>$signName, + ]); + $response = $client->send($request); + return $response->getBody()->getContents(); + } + } diff --git a/app/Admin/Common/Sms.php b/app/Admin/Common/Sms.php index 70df640..ced4e28 100644 --- a/app/Admin/Common/Sms.php +++ b/app/Admin/Common/Sms.php @@ -12,34 +12,6 @@ use Graze\GuzzleHttp\JsonRpc\Client; class Sms extends AdminController { - /** - * 发送短信 - * @throws ClientException - */ - public static function sent($params) - { - AlibabaCloud::accessKeyClient(env('ACCESS_KEY_ID'),env('ACCESS_SECRET')) - ->regionId('cn-shenzhen') - ->asDefaultClient(); - try { - $result = AlibabaCloud::rpc() - ->product('Dysmsapi') - ->version('2017-05-25') - ->action('SendSms') - ->method('POST') - ->host('dysmsapi.aliyuncs.com') - ->options([ - 'query' => $params, - ]) - ->request(); - dd($result); - }catch (ClientException $e){ - echo $e->getErrorMessage() . PHP_EOL; - }catch (ServerException $e){ - echo $e->getErrorMessage() . PHP_EOL; - } - } - /** * 远程RPC调用 * @param $phone @@ -48,16 +20,8 @@ class Sms extends AdminController * @param string $signName * @return string */ - public static function rpcSent($phone, $template, $templateParams, $signName='懒族生活') + public static function rpcSent($phone, $template, $templateParams, $signName) { - $client = Client::factory(env('RPC_SITE_HOST')); - $request = $client->request(uniqid(),'/alisms/sent', [ - 'phone' => $phone, - 'template'=>$template, - 'templateParams'=> json_encode($templateParams), - 'signName'=>$signName, - ]); - $response = $client->send($request); - return $response->getBody()->getContents(); + return Rpc::alisSmsSent($phone, $template, $templateParams, $signName); } }