API文档

PHP

方法一:
使用亿速云短信扩展 https://github.com/yisu-cloud/sms

方法二:

  1. <?php
  2. function sendSms() {
  3. $url = "https://api.yisu.com/sms/sendSms";
  4. $accessId = "*****";
  5. $accessSecret = "*****";
  6. $params = [
  7. "timestamp" => time(),
  8. "nonce" => mt_rand(0, 99999999),
  9. "accessId" => $accessId
  10. ];
  11. $params["phone"] = "13800000000";
  12. $params["templateCode"] = 100001;
  13. $params["templateVars"] = json_encode(["code"=>111111, "min"=>10], true);
  14. ksort($params);
  15. $signStr = "";
  16. foreach ( $params as $key => $value ) {
  17. $signStr = $signStr . $key . "=" . $value . "&";
  18. }
  19. $signStr = substr($signStr, 0, -1);
  20. $verifySignature = base64_encode(hash_hmac("sha1", $signStr, $accessSecret, true));
  21. $params["signature"] = $verifySignature;
  22. $data = http_build_query($params);
  23. $options = array(
  24. "http" => array(
  25. "method" => "POST",
  26. "header" => "Content-Type:application/x-www-form-urlencoded",
  27. "content" => $data
  28. ));
  29. $context = stream_context_create($options);
  30. $result = file_get_contents($url, FILE_TEXT, $context);
  31. return $result;
  32. }
  33. echo sendSms();
  34. ?>