JdMessageSend4.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 dxsendSms($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_177535339");
  26. //选填-假如模板中存在变量需要替换则为必填(JSON格式)
  27. $request->setTemplateParam(json_encode($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. var_dump($acsResponse->Message);
  36. $a=$acsResponse->Message;
  37. return $a;
  38. }
  39. /* $res = sendSms('15000011254','1233213');
  40. var_dump($res);*/
  41. //querySendDetails();
  42. ?>