System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
System.setProperty("sun.net.client.defaultReadTimeout", "10000");
IClientProfile profile = DefaultProfile.getProfile("cn-shanghai", accessKeyId, accessKeySecret);
try {
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
IAcsClient acsClient = new DefaultAcsClient(profile);
SingleCallByTtsRequest request = new SingleCallByTtsRequest();
//必填-被叫显号,可在语音控制台中找到所购买的显号
request.setCalledShowNumber(aliMessage.getShowNumber());
//必填-被叫号码
request.setCalledNumber(aliMessage.getPhone());
//必填-Tts模板ID
request.setTtsCode(aliMessage.getTempId());
//可选-当模板中存在变量时需要设置此值
request.setTtsParam(aliMessage.getCode());
//可选-音量 取值范围 0--200
request.setVolume(100);
//可选-播放次数
request.setPlayTimes(3);
//hint 此处可能会抛出异常,注意catch
SingleCallByTtsResponse singleCallByTtsResponse = acsClient.getAcsResponse(request);
if (singleCallByTtsResponse.getCode() != null && singleCallByTtsResponse.getCode()
.equals("OK")) {
//请求成功
log.info("语音文本外呼---------------");
log.info("RequestId=" + singleCallByTtsResponse.getRequestId());
log.info("Code=" + singleCallByTtsResponse.getCode());
log.info("Message=" + singleCallByTtsResponse.getMessage());
log.info("CallId=" + singleCallByTtsResponse.getCallId());
}
} catch (ClientException e) {
log.error(e.getErrCode(), e);
e.printStackTrace();
}
按照demo上的内容写的,还是报错
com.aliyuncs.exceptions.ClientException: SDK.InvalidRegionId : Can not find endpoint to access.
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。