短信模板不合法(不存在或被拉黑)

  if (StringUtils.isEmpty(PhoneNumbers)) return false;

            DefaultProfile profile =
                    DefaultProfile.getProfile("default", "你的key", "你的value");
            IAcsClient client = new DefaultAcsClient(profile);
            CommonRequest request = new CommonRequest();
            //request.setProtocol(ProtocolType.HTTPS);
            request.setMethod(MethodType.POST);
            request.setDomain("dysmsapi.aliyuncs.com");
            request.setVersion("2017-05-25");
            request.setAction("SendSms");

            request.putQueryParameter("PhoneNumbers", 手机号码);
            request.putQueryParameter("SignName", 签名");
            request.putQueryParameter("TemplateCode", 模板code);
            //注意这里需要传json
            request.putQueryParameter("TemplateParam", JSONObject.toJSONString(param));

            try {
                CommonResponse response = client.getCommonResponse(request);
                System.out.println(response.getData());
                return response.getHttpResponse().isSuccess();
            } catch (Exception e) {
                System.out.println(
                        "短信发送异常"
                );
            }

先检查代码有没有错误,然后不要用简单的验证码即可,例如:1234…

你可能感兴趣的:(巨坑及常用解决方法,错误日记,post,http,web,spring)