12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- include 'aliyun-php-sdk-core/Config.php';
- include_once 'Dysmsapi/Request/V20170525/SendSmsRequest.php';
- include_once 'Dysmsapi/Request/V20170525/QuerySendDetailsRequest.php';
- function sendSms($Tel,$Verify) {
-
- //此处需要替换成自己的AK信息
- $accessKeyId = "LTAI9WERPIFIlHDg";
- $accessKeySecret = "p7SQ0rYpraebcdoJ0l3tOtYmmgrR4q";
- //短信API产品名
- $product = "Dysmsapi";
- //短信API产品域名
- $domain = "dysmsapi.aliyuncs.com";
- //暂时不支持多Region
- $region = "cn-hangzhou";
-
- //初始化访问的acsCleint
- $profile = DefaultProfile::getProfile($region, $accessKeyId, $accessKeySecret);
- DefaultProfile::addEndpoint("cn-hangzhou", "cn-hangzhou", $product, $domain);
- $acsClient= new DefaultAcsClient($profile);
-
- $request = new Dysmsapi\Request\V20170525\SendSmsRequest;
- //必填-短信接收号码
- $request->setPhoneNumbers($Tel);
- //必填-短信签名
- $request->setSignName("永天智慧云");
- //必填-短信模板Code
- $request->setTemplateCode("SMS_164095840");
- //选填-假如模板中存在变量需要替换则为必填(JSON格式)
- $request->setTemplateParam("{\"code\":\"".$Verify."\"}");
- // print_r('测试1'.$Verify);
- // print_r($request);
- //选填-发送短信流水号
- $request->setOutId("1234");
- //发起访问请求
- $acsResponse = $acsClient->getAcsResponse($request);
- //get_object_vars($acsResponse);
- // var_dump($acsResponse->Message);
- }
- /* $res = sendSms('15000011254','1233213');
- var_dump($res);*/
- //querySendDetails();
- ?>
|