a.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 = "LTAIGLgTqzcOurX3";
  8. $accessKeySecret = "zt2zp2T5wo8MXDHGxyFW43ykf8plzw";
  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_130927556");
  26. //选填-假如模板中存在变量需要替换则为必填(JSON格式)
  27. $request->setTemplateParam("{\"codec\":\"".$Verify."\"}");
  28. //print_r($request);
  29. //选填-发送短信流水号
  30. $request->setOutId("1234");
  31. //发起访问请求
  32. $acsResponse = $acsClient->getAcsResponse($request);
  33. //get_object_vars($acsResponse);
  34. var_dump($acsResponse->Message);
  35. }
  36. /* $res = sendSms('15000011254','1233213');
  37. var_dump($res);*/
  38. //querySendDetails();
  39. ?>