1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?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 = "LTAIGLgTqzcOurX3";
- $accessKeySecret = "zt2zp2T5wo8MXDHGxyFW43ykf8plzw";
- //短信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_130927556");
- //选填-假如模板中存在变量需要替换则为必填(JSON格式)
- $request->setTemplateParam("{\"codec\":\"".$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();
- ?>
|