当前位置:网站首页>集成阿里云短信服务以及报签名不合法的原因
集成阿里云短信服务以及报签名不合法的原因
2022-06-24 03:55:00 【Granger_g】
集成阿里云短信服务 ,以下是我集成阿里云短信服务成功收到短信的代码:
里面的一些内容需要改成你自己的阿里云配置
public class TestSms {
public static void main(String[] args) {
DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou",
"<accessKeyId>",
"<accessSecret>");//这两个地方写你的对应 Id 和Secret
IAcsClient client = new DefaultAcsClient(profile);
CommonRequest request = new CommonRequest();
request.setSysMethod(MethodType.POST);
request.setSysDomain("dysmsapi.aliyuncs.com");
request.setSysVersion("2017-05-25");
request.setSysAction("SendSms");
request.putQueryParameter("RegionId", "cn-hangzhou");
//确定发送的电话号码和 验证码
request.putQueryParameter("PhoneNumbers", "13100000000");
request.putQueryParameter("TemplateParam", "{\"code\":\"" + "123456" + "\"}");
//确定是的模版和签名
request.putQueryParameter("SignName", "这里填你申请的短信签名");
request.putQueryParameter("TemplateCode", "这里写你的模版code");
// RAM账号AccessKey Secret
try {
CommonResponse response = client.getCommonResponse(request);
System.out.println(response.getData());
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
e.printStackTrace();
}
}
}如果一切正常上面的代码 就都搞定了,可以直接收取到短信。
遇到的问题1:签名不合法
解决办法:
1.检查你的 accessKeyId 和 accessSecret 是否都对了
2.检查你的 短信签名 和模版code 注意:模版code 是一串SMS_1995992 这样的数字,不要把模版名称填上了
3.编码问题,如果你的短信签名是中文的,改一下编码方式试试。(我的问题就出在这,我改成GBK编码方式就ok了)
边栏推荐
- [2021 "shadow seeking" medical artificial intelligence algorithm competition] frequently asked questions related to Ti-One products
- [new light weight first purchase special] 1-core 2g5m light weight application server costs 50 yuan in the first year. It is cost-effective and helps you get on the cloud easily!
- Making a Chatbot based on gpt2
- C language linked list points to the next structure pointer, structure and its many small details
- uni-app进阶之认证【day12】
- Demonstration of C language structure function research
- Wide & deep model and optimizer understand code practice
- The use of char[0] and char[1] in C language structure
- Notice on stopping maintenance of this column
- openEuler社区理事长江大勇:共推欧拉开源新模式 共建开源新体系
猜你喜欢

openEuler Kernel 技术分享第 20 期 | 执行实体创建与切换

Clang code coverage detection (pile insertion technology)
![Web technology sharing | [map] to realize customized track playback](/img/b2/25677ca08d1fb83290dd825a242f06.png)
Web technology sharing | [map] to realize customized track playback

微博国际版更名为微博轻享版

一款支持内网脱机分享文档的接口测试软件

External network access SVN server (external network access SVN server deployed on the cloud)

Application practice | Apache Doris integrates iceberg + Flink CDC to build a real-time federated query and analysis architecture integrating lake and warehouse

Multi task video recommendation scheme, baidu engineers' actual combat experience sharing

祝贺钟君成为 CHAOSS Metric Model 工作组的 Maintainer

15+城市道路要素分割应用,用这一个分割模型就够了
随机推荐
Introduction to C language custom types (structure, enumeration, union, bit segment)
Brief introduction: how much do you know about supply chain attacks
mysql - sql执行过程
Abnova膜蛋白脂蛋白体解决方案
Troubleshoot the high memory consumption of Go program
How to monitor the operation of easygbs service in real time?
Cloud development CMS Enterprise Edition demand survey
Understanding of structure in C language
Worthington脱氧核糖核酸酶I特异性和相关研究
Notice on stopping maintenance of this column
"The first share of Chinese member e-commerce" gathered in the anti reptile attack and defense war | talk with industrial security experts
What is a 1U server? What industries can 1U servers be used in?
数据库解答建标,按要求回答
Mac CentOS installation phpredis
From virtual to real, digital technology makes rural funds "live"
Easyanticheat uses to inject unsigned code into a protected process (2)
uni-app进阶之认证【day12】
Naming of tables in MySQL
Ribbon
web技术分享| 【地图】实现自定义的轨迹回放