首先安装
compor require alibabacloud/sdk
接着看alibabacloud官网文档
示例
my_compor_aliyunsms.php
<?php// u swoft\task\bean\annotation\task;// u alibabacloud\client\alibabacloud;// u alibabacloud\client\exception\clientexception;// u alibabacloud\client\exception\rverexception;u alibabacloud\client\alibabacloud;u alibabacloud\client\exception\clientexception;u alibabacloud\client\exception\rve教室里的掌声作文rexception;u alibabacloud\ecs\ecs;/** * 阿里信息发送类 * @task("ali") */class my_c幼时记趣ompor_aliyunsms{ /** * 发送短信验证码 */ public function ndcode($config,$phone,$code) { $param = [ 'code' => $code ]; alibabacloud::accesskeyclient($config['accesskeyid'], $config['accesscret']) ->regionid($config['regionid']) ->asglobalclient(); try { $result = alibabacloud::rpcrequest() -家长会小结>product('dysmsapi') ->version('2017-05-25') 燃烧歌词->action('ndsms') ->method('post') ->options([ 'query' => [ 'phonenumbers' => $phone, 'signname' => $config['signname'], 'templatecode' => $config['templateco徐志摩爱情诗de'], 'templateparam' => json_encode($param) ], ]) ->request(); return $result->toarray(); } catch (clientexception $e) { echo $e->geterrormessage() . php_eol; } catch (rverexception $e) { echo $e->geterrormessage() . php_eol; } }}
demo
include 'my_compor_aliyunsms.php'; $sms = new my_compor_aliyunsms(); $phone='xxxxxx'; $code='99999'; $config = [ 'accesskeyid' => 'ltaimje******hs', 'accesscret' => 'fmuqtlurkqn******z2m07', 'signname' => '****', 'templatecode' => 'sms_****04', 'regionid' => 'cn-hangzhou' ]; $re = $sms->ndcode($config,$phone,$code); var_dump($re);
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持www.887551.com。
本文发布于:2023-04-07 07:51:55,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/76c77309122b2ae245f043b944df7214.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:PHP如何实现阿里云短信sdk灵活应用在项目中的方法.doc
本文 PDF 下载地址:PHP如何实现阿里云短信sdk灵活应用在项目中的方法.pdf
留言与评论(共有 0 条评论) |