本章节为您介绍了阿里云语音服务语音通知的功能介绍和实现方法,您可以通过调用QueryCallDetailByCallId查询通话记录详情。

功能介绍

当您调用接口成功实现语音通知、语音验证码、语音IVR、点击拨号、智能外呼功能,您可以调用QueryCallDetailByCallId根据接口返回的CallId查询某个时间点的通话记录。

实现方法

在调用API实现该功能前,您需要完成以下操作:

  • 购买语音号码并审核通过语音模板或语音文件,具体操作请参见快速入门
  • 获取AccessKey信息,详情请参见获取AccessKey
  • 完成本地SDK环境搭建,详情请参见Pyhton SDK

本章节调用接口详情,请参见QueryCallDetailByCallId

from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.acs_exception.exceptions import ClientException
from aliyunsdkcore.acs_exception.exceptions import ServerException
from aliyunsdkdyvmsapi.request.v20170525.QueryCallDetailByCallIdRequest import QueryCallDetailByCallIdRequest

client = AcsClient('<accessKeyId>', '<accessSecret>', 'cn-hangzhou')
request = QueryCallDetailByCallIdRequest()
request.set_accept_format('json')
request.set_CallId("100625930001^10019107xx")
request.set_ProdId(11000000300004)
request.set_QueryDate(1577255564)
response = client.do_action_with_exception(request)
print(response)

正常返回结果如下所示:

{       
    "Data":{"caller":"1876713xx","startDate":"","stateDesc":"502","duration":0,"callerShowNumber":"0534475xx","gmtCreate":"2019-12-24 20:09:06","state":"502","endDate":"","calleeShowNumber":"0534475xx","callee":"1373546xx"}
    "Message": "OK",
    "RequestId": "A5291B00-1036-4CA2-8BFD-1238B784C9BA",
    "Code": "OK"
}

调用SDK返回错误码,详情请参见错误码列表