当前位置:网站首页>集成阿里云短信服务以及报签名不合法的原因
集成阿里云短信服务以及报签名不合法的原因
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了)
边栏推荐
- Easygbs video playback protocol only webrtc can play. Troubleshooting
- 3. go deep into tidb: perform optimization explanation
- Apipost interface assertion details
- 应用实践 | Apache Doris 整合 Iceberg + Flink CDC 构建实时湖仓一体的联邦查询分析架构
- Indicator statistics: real time uvpv statistics based on flow computing Oceanus (Flink)
- To the world's first full frame 3D games!
- Web penetration test - 5. Brute force cracking vulnerability - (9) MS-SQL password cracking
- Worthington胰蛋白酶的物化性质及特异性
- Next. JS + cloud development webify creates an excellent website
- [2021 "shadow seeking" medical artificial intelligence algorithm competition] Ti-One product use tutorial
猜你喜欢

共建欧拉社区 共享欧拉生态|携手麒麟软件 共创数智未来

英特尔 XTU 官方超频工具已支持 Win11 22H2 和 13 代酷睿 Raptor Lake 处理器

Abnova荧光原位杂交(FISH)探针解决方案

ServiceStack. Source code analysis of redis (connection and connection pool)

Clang代码覆盖率检测(插桩技术)

祝贺钟君成为 CHAOSS Metric Model 工作组的 Maintainer
2020年Android面试题汇总(中级)

博士申请 | 香港科技大学(广州)刘浩老师招收数据挖掘方向全奖博士/硕士

mysql - sql执行过程

The official overclocking tool of Intel XTU supports win11 22h2 and 13th generation core Raptor Lake processors
随机推荐
Cloud development CMS Enterprise Edition demand survey
How to modify the channel name registered by the camera in the easygbs national standard platform?
Summary of Android interview questions in 2020 (elementary)
15+城市道路要素分割应用,用这一个分割模型就够了
Kubernetes 资源拓扑感知调度优化
openEuler Kernel 技术分享第 20 期 | 执行实体创建与切换
C language - number of bytes occupied by structure
Methods of creating and modifying shell script files in batch
Demonstration of the processing of divisor 0 in SQL
mysql中表的命名
Mac CentOS installation phpredis
Web penetration test - 5. Brute force cracking vulnerability - (8) PostgreSQL password cracking
web渗透测试----5、暴力破解漏洞--(5)SMB密码破解
Wide & deep model and optimizer understand code practice
[hot promotion] Tencent cloud enterprise cloud disk solution
Configuration process of easygbs access to law enforcement recorder
Easyanticheat uses to inject unsigned code into a protected process (2)
[Mid Autumn Festival greeting new year with good gifts] Tengyun pioneer feedback exchange group received new benefits!
Notice on stopping maintenance of this column
15+ urban road element segmentation application, this segmentation model is enough