发送短信(阿里云短信发送方式)

Posted wpfphp

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了发送短信(阿里云短信发送方式)相关的知识,希望对你有一定的参考价值。

/*
 * 发送短信(阿里云短信发送方式)
 */
function sms($code,$mobile,$string)
   $iClientProfile = DefaultProfile::getProfile("cn-hangzhou", "", "");
   $client = new DefaultAcsClient($iClientProfile);
   $request = new Sms\\SingleSendSmsRequest();
   $request->setSignName("公司名称");/*签名名称*/
   $request->setTemplateCode($code);/*模板code*/
   $request->setRecNum($mobile);/*目标手机号*/
   $request->setParamString($string);/*模板变量,数字一定要转换为字符串*/
   try 
      $response = $client->getAcsResponse($request);
//    print_r($response);
   
   catch (ClientException  $e) 
//    print_r($e->getErrorCode());
//    echo "<br>";
//    print_r($e->getErrorMessage());
   
   catch (ServerException  $e) 
//    print_r($e->getErrorCode());
//    print_r($e->getErrorMessage());
   

以上是关于发送短信(阿里云短信发送方式)的主要内容,如果未能解决你的问题,请参考以下文章