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.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
< ? php
namespace ali\alibabacloud\message ;
use AlibabaCloud\SDK\Dysmsapi\V20170525\Models\SendSmsRequest ;
class Message extends Base
{
/**
* 发送短信
* @param string $mobile_phone 接收短信号码 支持对多个手机号码发送短信,手机号码之间以英文逗号(,) 分隔。上限为1000个手机号码。批量调用相对于单条调用及时性稍有延迟。
* @param string $template_code 模板ID
* @param array $template_param 短信模板变量对应的实际值
* @param string $sign_name 短信签名 必须是已添加、并通过审核的短信签名
* @date 2021-03-26
*/
public function sendSms ( $mobile_phone , $template_code , $template_param = [], $sign_name = '' )
{
$client = self :: createClient ();
$data = [
" phoneNumbers " => $mobile_phone ,
" signName " => $sign_name ,
" templateCode " => $template_code ,
" templateParam " => json_encode ( $template_param )
];
$sendSmsRequest = new SendSmsRequest ( $data );
// 复制代码运行请自行打印 API 的返回值
$result = $client -> sendSms ( $sendSmsRequest );
$result_array = $result -> toMap ();
$result = $result_array [ 'body' ];
// 记录日志
$uid = defined ( 'UID' ) ? UID : '' ;
platformLog ( $data , $result , 'alibaba_cloud_message_send_message_uid_' . $uid );
return $result ;
}
}