12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?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 = "LTAISIKNr3IJRm47";
- $accessKeySecret = "i5uCDgTiO16ogCXqxawdj91Vuy6ThO";
- //短信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_75870017");
- //选填-假如模板中存在变量需要替换则为必填(JSON格式)
- $request->setTemplateParam("{\"codec\":\"".$Verify."\"}");
- //print_r($request);
- //选填-发送短信流水号
- $request->setOutId("1234");
- //发起访问请求
- $acsResponse = $acsClient->getAcsResponse($request);
- //get_object_vars($acsResponse);
- var_dump($acsResponse->Message);
- }
- function querySendDetails() {
-
- //此处需要替换成自己的AK信息
- $accessKeyId = "LTAISIKNr3IJRm47";
- $accessKeySecret = "i5uCDgTiO16ogCXqxawdj91Vuy6ThO";
- //短信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\QuerySendDetailsRequest();
- //必填-短信接收号码
- $request->setPhoneNumber("15000011254");
- //选填-短信发送流水号
- $request->setBizId("abcdefgh");
- //必填-短信发送日期,支持近30天记录查询,格式yyyyMMdd
- $request->setSendDate("20170525");
- //必填-分页大小
- $request->setPageSize(10);
- //必填-当前页码
- $request->setContent(1);
-
- //发起访问请求
- $acsResponse = $acsClient->getAcsResponse($request);
- var_dump($acsResponse);
-
- }
- $res = sendSms('17321172378','66688');
- var_dump($res);
- querySendDetails();
- ?>
|