JdMessageSend3.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. include 'aliyun-php-sdk-core/Config.php';
  3. include_once 'Dysmsapi/Request/V20170525/SendSmsRequest.php';
  4. include_once 'Dysmsapi/Request/V20170525/QuerySendDetailsRequest.php';
  5. function sendSms($Tel,$Verify) {
  6. //此处需要替换成自己的AK信息
  7. $accessKeyId = "LTAI9WERPIFIlHDg";
  8. $accessKeySecret = "p7SQ0rYpraebcdoJ0l3tOtYmmgrR4q";
  9. //短信API产品名
  10. $product = "Dysmsapi";
  11. //短信API产品域名
  12. $domain = "dysmsapi.aliyuncs.com";
  13. //暂时不支持多Region
  14. $region = "cn-hangzhou";
  15. //初始化访问的acsCleint
  16. $profile = DefaultProfile::getProfile($region, $accessKeyId, $accessKeySecret);
  17. DefaultProfile::addEndpoint("cn-hangzhou", "cn-hangzhou", $product, $domain);
  18. $acsClient= new DefaultAcsClient($profile);
  19. $request = new Dysmsapi\Request\V20170525\SendSmsRequest;
  20. //必填-短信接收号码
  21. $request->setPhoneNumbers($Tel);
  22. //必填-短信签名
  23. $request->setSignName("永天智慧云");
  24. //必填-短信模板Code
  25. $request->setTemplateCode("SMS_164095840");
  26. //选填-假如模板中存在变量需要替换则为必填(JSON格式)
  27. $request->setTemplateParam("{\"code\":\"".$Verify."\"}");
  28. // print_r('测试1'.$Verify);
  29. // print_r($request);
  30. //选填-发送短信流水号
  31. $request->setOutId("1234");
  32. //发起访问请求
  33. $acsResponse = $acsClient->getAcsResponse($request);
  34. //get_object_vars($acsResponse);
  35. return $acsResponse->Message;
  36. // var_dump($acsResponse->Message);
  37. }
  38. /* $res = sendSms('15000011254','1233213');
  39. var_dump($res);*/
  40. //querySendDetails();
  41. ?>