本章节为您介绍了调用ClickToDial实现阿里云语音通知点击呼叫功能。
功能介绍
点击呼叫是指通过调用语音服务接口,通过语音服务分配的号码分别向主叫、被叫发起呼叫,双方接通后建立起正常通话,通话双方显示的号码均为语音服务平台号码。常用于企业办公电话等,例如钉钉办公电话。通过点击呼叫接口,可隐藏通话双方真实号码,同时平台可留存双方通话记录。
实现方法
实现点击呼叫功能前,您需要完成以下操作。
- 购买语音号码并审核通过语音模板或语音文件,具体操作请参见快速入门。
- 获取AccessKey信息,详情请参见获取AccessKey。
- 完成本地SDK环境搭建,详情请参见Java SDK。
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;
import com.alibaba.fastjson.JSON;
public class ClickToDial {
public static void main(String[] args) {
DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "<accessKeyId>", "<accessSecret>");
IAcsClient client = new DefaultAcsClient(profile);
CommonRequest request = new CommonRequest();
request.setMethod(MethodType.POST);
request.setDomain("dyvmsapi.aliyuncs.com");
request.setVersion("2017-05-25");
request.setAction("ClickToDial");
request.putQueryParameter("CallerShowNumber", "123xxxx");
request.putQueryParameter("CallerNumber", "1575xxxx");
request.putQueryParameter("CalledShowNumber", "12xxxx");
request.putQueryParameter("CalledNumber", "1885xxxx");
try {
CommonResponse response = client.getCommonResponse(request);
System.out.println(JSON.toJSONString(response.getData()));
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
e.printStackTrace();
}
}
}
正常返回结果如下所示:
{
"Message": "OK",
"RequestId": "762104B0-D58A-4D04-8486-7C5171D0D756",
"Code": "OK",
"CallId": "118720797955^10551795xx"
}
调用SDK返回错误码,详情请参见错误码列表。
在文档使用中是否遇到以下问题
更多建议
匿名提交