Home > Article > PHP Framework > Example to explain how TP framework integrates Huawei Cloud SMS service
The following thinkphp framework tutorial column will introduce to you how ThinkPHP integrates Huawei Cloud SMS Service. I hope it will be helpful to friends in need!
ThinkPHP integrates Huawei Cloud SMS service
This project integrates Huawei Cloud SMS sending service and supports ThinkPHP5.0 and ThinkPHP5. 1 and ThinkPHP6.0, maintained by Ningbo Shengjia Network Technology Co., Ltd.
Installation tutorial
Use composer require singka/singka-hwsms
to install from the command line. [Recommended learning: "thinkPHP Video Tutorial"]
Usage examples (based on ThinkPHP6.0)
<?php // +---------------------------------------------------------------------- // | 胜家云 [ SingKa Cloud ] // +---------------------------------------------------------------------- // | Copyright (c) 2016~2020 https://www.singka.net All rights reserved. // +---------------------------------------------------------------------- // | 宁波晟嘉网络科技有限公司 // +---------------------------------------------------------------------- // | Author: ShyComet <shycomet@qq.com> // +---------------------------------------------------------------------- namespace app\home\controller; use SingKa\HwSms\HwSms; class Index { /** * 短信发送示例 * * @url 华为云短信APP接入地址+接口访问URI * @appKey 华为云短信appKey * @appSecret 华为云短信appSecret * @sender 国内短信签名通道号或国际/港澳台短信通道号 * @signature 华为云短信签名 * @statusCallback 短信发送状态返回接收地址,可以为空 */ public function smsDemo() { $config['url'] = 'https://rtcsms.cn-north-1.myhuaweicloud.com:10743'; $config['appKey'] = 'PkT889B*************wM0GAi'; $config['appSecret'] = 'U58fd****************0o4N'; $config['sender'] = 'csms12345678'; $config['signature'] = '短信签名'; $config['statusCallback'] = '短信发送状态返回接收地址,可以为空'; $sms = new HwSms($config); $result = $sms->send('模板ID', '手机号码(多个号码可以用英文逗号隔开)', '短信变量数组'); if ($result['code'] == '000000') { echo '发送成功'; } else { echo $result['msg']; } } }
Other instructions
华为云短信介绍:https://support.huaweicloud.com/productdesc-msgsms/sms_desc.html
The above is the detailed content of Example to explain how TP framework integrates Huawei Cloud SMS service. For more information, please follow other related articles on the PHP Chinese website!