6 changed files with 211 additions and 13 deletions
-
63app/Admin/Common/Sms.php
-
28app/Admin/Controllers/LanzuMpWithdrawController.php
-
64app/Admin/Controllers/Test.php
-
1app/Admin/routes.php
-
1composer.json
-
67composer.lock
@ -0,0 +1,63 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\Admin\Common; |
|||
|
|||
|
|||
use AlibabaCloud\Client\AlibabaCloud; |
|||
use AlibabaCloud\Client\Exception\ClientException; |
|||
use AlibabaCloud\Client\Exception\ServerException; |
|||
use Dcat\Admin\Controllers\AdminController; |
|||
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 |
|||
* @param $template |
|||
* @param $templateParams |
|||
* @param string $signName |
|||
* @return string |
|||
*/ |
|||
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(); |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue