类 BaiduUtils

java.lang.Object
org.dromara.sms4j.baidu.utils.BaiduUtils

public class BaiduUtils extends Object
  • 构造器详细资料

    • BaiduUtils

      public BaiduUtils()
  • 方法详细资料

    • authStringPrefix

      private static String authStringPrefix(String accessKeyId)
      创建前缀字符串
      参数:
      accessKeyId - 访问密钥ID
      返回:
      bce-auth-v1/{accessKeyId}/{timestamp}/{expirationPeriodInSeconds }
    • canonicalRequest

      private static String canonicalRequest(String host, String action, String clientToken)
      创建规范请求
      参数:
      host - Host域
      action - 接口名称
      clientToken - 幂等性参数
      返回:
      HTTP Method + "\n" + CanonicalURI + "\n" + CanonicalQueryString + "\n" + CanonicalHeaders
    • canonicalURI

      private static String canonicalURI(String action)
      Formatting the URL with signing protocol.
      参数:
      action - URI
      返回:
      UriEncodeExceptSlash
    • canonicalQueryString

      private static String canonicalQueryString(String clientToken)
      Formatting the query string with signing protocol.
      参数:
      clientToken - 幂等性参数
      返回:
      String
    • canonicalHeaders

      private static String canonicalHeaders(String host)
      Formatting the headers from the request based on signing protocol.
      参数:
      host - only host
      返回:
      String
    • sha256Hex

      private static String sha256Hex(String key, String str)
      HMAC-SHA256-HEX
      参数:
      key - 密钥
      str - 要加密的字符串
      返回:
      小写形式的十六进制字符串
    • buildHeaders

      public static Map<String,String> buildHeaders(BaiduConfig config, String clientToken)
      构造 HTTP Headers请求头
      参数:
      config - 百度智能云配置
      clientToken - 幂等性参数
      返回:
      Headers请求头
    • buildBody

      public static Map<String,Object> buildBody(String mobile, String template, String signatureId, LinkedHashMap<String,String> contentVar, String custom, String userExtId)
      构造 HTTP Body 请求体
      参数:
      mobile - 手机号码 支持单个或多个手机号,多个手机号之间以英文逗号分隔
      template - 短信模板ID,模板申请成功后自动创建,全局内唯一
      signatureId - 短信签名ID,签名表申请成功后自动创建,全局内唯一
      contentVar - 模板变量内容,用于替换短信模板中定义的变量
      custom - 用户自定义参数,格式为字符串,状态回调时会回传该值
      userExtId - 通道自定义扩展码,上行回调时会回传该值,其格式为纯数字串。默认为不开通,请求时无需设置该参数。如需开通请联系SMS帮助申请
      返回:
      Body 请求体