package com.cummins.aliyun.message.message;
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 class SendMessage {
public static void main(String[] args) {
String accessKey_ID = "xxx";
String AccessKey_Secret = "xxx";
DefaultProfile profile = DefaultProfile.getProfile("cn-qingdao", accessKey_ID, AccessKey_Secret);
IAcsClient client = new DefaultAcsClient(profile);
CommonRequest request = new CommonRequest();
request.setSysMethod(MethodType.POST);//调用方式
//request.setSysDomain("dysmsapi.aliyuncs.com");
request.setSysDomain("106.11.45.35");
request.setSysVersion("2017-05-25");//版本
request.setSysAction("SendSms");//系统规定参数
request.putQueryParameter("PhoneNumbers", "xxx");
request.putQueryParameter("SignName", "xxx");
request.putQueryParameter("TemplateCode", "xxx"); //通用通知模板
request.putQueryParameter("TemplateParam", "{\"code\":\"message_test_cummins\"}");
try {
System.out.println("request:"+request);
CommonResponse resp = client.getCommonResponse(request);
System.out.println(resp);
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
e.printStackTrace();
}
}
}
Exception in thread "main" java.lang.IllegalStateException: Server response has a bad format type: RAW at com.aliyuncs.reader.ReaderFactory.createInstance(ReaderFactory.java:16) at com.aliyuncs.DefaultAcsClient.readError(DefaultAcsClient.java:420) at com.aliyuncs.DefaultAcsClient.getCommonResponse(DefaultAcsClient.java:174) at com.cummins.aliyun.message.message.SendMessage.main(SendMessage.java:32)
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。