$data = input('phone');
$random = rand(0,9999);
AlibabaCloud::accessKeyClient('LTAI5t88SfZ5yhH4Sgu1u3gt', 'vbLBZWvzazGZvJpPap20ZyKDoBbdq2')
->regionId('ap-northeast-1')
->asDefaultClient();
try {
$result = AlibabaCloud::rpc()
->product('Dysmsapi')
// ->scheme('https') // https | http
->version('2017-05-25')
->action('SendSms')
->method('POST')
->host('dysmsapi.aliyuncs.com')
->options([
'query' => [
'PhoneNumbers' => $data,
'SignName' => "全代码",
'TemplateCode' => "SMS_221120254",
'TemplateParam' => "{\"code\":\"$random\"}",
],
])
->request();
cache('code',$random,'300');
print_r($result->toArray());
} catch (ClientException $e) {
echo $e->getErrorMessage() . PHP_EOL;
} catch (ServerException $e) {
echo $e->getErrorMessage() . PHP_EOL;
}
阿里云手机号验证码
最新推荐文章于 2021-12-15 11:30:22 发布