阿里云短信服务报错:SignatureDoesNotMatch : Specified signature is not matched with our calculation.

报错内容:

com.aliyuncs.exceptions.ClientException: SignatureDoesNotMatch : Specified signature is not matched with our calculation. server string to sign is:POST&%2F&AccessKeyId%3********************%26Action%3DSendSms%26Format%3DJSON%26PhoneNumbers%3D***********%26RegionId%3Dcn-hangzhou%26SignName%3D%25E4%25B9%25****5C%2598%25E5%2595%2586%25E5%259F%258E%26SignatureMethod%3DHMAC-SHA1%26SignatureNonce%3Da4b04-d25f-4c2d-9766-a543f63e2ca9%26SignatureVersion%3D1.0%26TemplateCode%3DSMS_19****605%26TemplateParam%3D%257B%25**code%2522%253A%2522123456%2522%257D%26Timestamp%3D2020-11-27T03%253A30%253A13Z%26Version%3D2017-05-25
RequestId : 40A383BD-0C85-467A-BA00-0619****9BD4

我最后调试出的问题是secret错误,没有更新。

调试步骤

一、用官方Api调试测试签名、模板是否可用

在这里插入图片描述二、把代码复制到本地,测试 accessKeyIdsecret是否可用

package com.zyark.beautiful.shop.modules.generator.common;
import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;


public static void main(String[] args) {
        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "************************", "***************************");
        IAcsClient client = new DefaultAcsClient(profile);

        CommonRequest request = new CommonRequest();
        request.setMethod(MethodType.POST);
        request.setDomain("dysmsapi.aliyuncs.com");
        request.setVersion("2017-05-25");
        request.setAction("SendSms");
        request.putQueryParameter("RegionId", "cn-hangzhou");
        request.putQueryParameter("PhoneNumbers", "*******************");
        request.putQueryParameter("SignName", "********");
        request.putQueryParameter("TemplateCode", "*****************");
        request.putQueryParameter("TemplateParam", "{\"code\":\"123456\"}");
        try {
            CommonResponse response = client.getCommonResponse(request);
            System.out.println(response.getData());
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }
    }
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值