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.
41 lines
1.1 KiB
41 lines
1.1 KiB
<?php
|
|
|
|
|
|
namespace App\Admin\Common;
|
|
|
|
|
|
use AlibabaCloud\Client\AlibabaCloud;
|
|
use AlibabaCloud\Client\Exception\ClientException;
|
|
use AlibabaCloud\Client\Exception\ServerException;
|
|
use Dcat\Admin\Controllers\AdminController;
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|