查询通话记录详情

本文为您介绍了如何调用QueryCallDetailByCallId接口查询通话记录详情。

功能介绍

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

准备工作

调用API查询通话记录之前,您需要完成以下操作:

代码示例

本示例展示了调用QueryCallDetailByCallId接口,查询通话记录详情。接口详情,请参见QueryCallDetailByCallId

如果您需要进行调试请参见使用OpenAPI Explorer

// This file is auto-generated, don't edit it. Thanks.
package com.aliyun.sample;

import com.aliyun.tea.*;
import com.aliyun.dyvmsapi20170525.*;
import com.aliyun.dyvmsapi20170525.models.*;
import com.aliyun.teaopenapi.*;
import com.aliyun.teaopenapi.models.*;

public class Sample {

    /**
     * 使用AK&SK初始化账号Client
     * @param accessKeyId
     * @param accessKeySecret
     * @return Client
     * @throws Exception
     */
    public static com.aliyun.dyvmsapi20170525.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
        Config config = new Config()
                // 您的AccessKey ID
                .setAccessKeyId(accessKeyId)
                // 您的AccessKey Secret
                .setAccessKeySecret(accessKeySecret);
        // 访问的域名
        config.endpoint = "dyvmsapi.aliyuncs.com";
        return new com.aliyun.dyvmsapi20170525.Client(config);
    }

    public static void main(String[] args_) throws Exception {
        java.util.List<String> args = java.util.Arrays.asList(args_);
        com.aliyun.dyvmsapi20170525.Client client = Sample.createClient("accessKeyId", "accessKeySecret");
        QueryCallDetailByCallIdRequest queryCallDetailByCallIdRequest = new QueryCallDetailByCallIdRequest()
                .setCallId("100625930001^10019107****")
                .setProdId(11000000300004)
                .setQueryDate(1577255564);
        // 复制代码运行请自行打印 API 的返回值
        client.queryCallDetailByCallId(queryCallDetailByCallIdRequest);
    }
}
# -*- coding: utf-8 -*-
# This file is auto-generated, don't edit it. Thanks.
import sys

from typing import List

from alibabacloud_dyvmsapi20170525.client import Client as Dyvmsapi20170525Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_dyvmsapi20170525 import models as dyvmsapi_20170525_models


class Sample:
    def __init__(self):
        pass

    @staticmethod
    def create_client(
        access_key_id: str,
        access_key_secret: str,
    ) -> Dyvmsapi20170525Client:
        """
        使用AK&SK初始化账号Client
        @param access_key_id:
        @param access_key_secret:
        @return: Client
        @throws Exception
        """
        config = open_api_models.Config(
            # 您的AccessKey ID,
            access_key_id=access_key_id,
            # 您的AccessKey Secret,
            access_key_secret=access_key_secret
        )
        # 访问的域名
        config.endpoint = 'dyvmsapi.aliyuncs.com'
        return Dyvmsapi20170525Client(config)

    @staticmethod
    def main(
        args: List[str],
    ) -> None:
        client = Sample.create_client('accessKeyId', 'accessKeySecret')
        query_call_detail_by_call_id_request = dyvmsapi_20170525_models.QueryCallDetailByCallIdRequest(
            call_id='100625930001^10019107****',
            prod_id=11000000300004,
            query_date=1577255564
        )
        # 复制代码运行请自行打印 API 的返回值
        client.query_call_detail_by_call_id(query_call_detail_by_call_id_request)

    @staticmethod
    async def main_async(
        args: List[str],
    ) -> None:
        client = Sample.create_client('accessKeyId', 'accessKeySecret')
        query_call_detail_by_call_id_request = dyvmsapi_20170525_models.QueryCallDetailByCallIdRequest(
            call_id='100625930001^10019107****',
            prod_id=11000000300004,
            query_date=1577255564
        )
        # 复制代码运行请自行打印 API 的返回值
        await client.query_call_detail_by_call_id_async(query_call_detail_by_call_id_request)


if __name__ == '__main__':
    Sample.main(sys.argv[1:])
// This file is auto-generated, don't edit it. Thanks.
package main

import (
  "os"
  dyvmsapi20170525  "github.com/alibabacloud-go/dyvmsapi-20170525/v2/client"
  openapi  "github.com/alibabacloud-go/darabonba-openapi/client"
  "github.com/alibabacloud-go/tea/tea"
)


/**
 * 使用AK&SK初始化账号Client
 * @param accessKeyId
 * @param accessKeySecret
 * @return Client
 * @throws Exception
 */
func CreateClient (accessKeyId *string, accessKeySecret *string) (_result *dyvmsapi20170525.Client, _err error) {
  config := &openapi.Config{
    // 您的AccessKey ID
    AccessKeyId: accessKeyId,
    // 您的AccessKey Secret
    AccessKeySecret: accessKeySecret,
  }
  // 访问的域名
  config.Endpoint = tea.String("dyvmsapi.aliyuncs.com")
  _result = &dyvmsapi20170525.Client{}
  _result, _err = dyvmsapi20170525.NewClient(config)
  return _result, _err
}

func _main (args []*string) (_err error) {
  client, _err := CreateClient(tea.String("accessKeyId"), tea.String("accessKeySecret"))
  if _err != nil {
    return _err
  }

  queryCallDetailByCallIdRequest := &dyvmsapi20170525.QueryCallDetailByCallIdRequest{
    CallId: tea.String("100625930001^10019107****"),
    ProdId: tea.Int64(11000000300004),
    QueryDate: tea.Int64(1577255564),
  }
  // 复制代码运行请自行打印 API 的返回值
  _, _err = client.QueryCallDetailByCallId(queryCallDetailByCallIdRequest)
  if _err != nil {
    return _err
  }
  return _err
}


func main() {
  err := _main(tea.StringSlice(os.Args[1:]))
  if err != nil {
    panic(err)
  }
}
<?php

// This file is auto-generated, don't edit it. Thanks.
namespace AlibabaCloud\SDK\Sample;

use AlibabaCloud\SDK\Dyvmsapi\V20170525\Dyvmsapi;

use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\SDK\Dyvmsapi\V20170525\Models\QueryCallDetailByCallIdRequest;

class Sample {

    /**
     * 使用AK&SK初始化账号Client
     * @param string $accessKeyId
     * @param string $accessKeySecret
     * @return Dyvmsapi Client
     */
    public static function createClient($accessKeyId, $accessKeySecret){
        $config = new Config([
            // 您的AccessKey ID
            "accessKeyId" => $accessKeyId,
            // 您的AccessKey Secret
            "accessKeySecret" => $accessKeySecret
        ]);
        // 访问的域名
        $config->endpoint = "dyvmsapi.aliyuncs.com";
        return new Dyvmsapi($config);
    }

    /**
     * @param string[] $args
     * @return void
     */
    public static function main($args){
        $client = self::createClient("accessKeyId", "accessKeySecret");
        $queryCallDetailByCallIdRequest = new QueryCallDetailByCallIdRequest([
            "callId" => "100625930001^10019107****",
            "prodId" => 11000000300004,
            "queryDate" => 1577255564
        ]);
        // 复制代码运行请自行打印 API 的返回值
        $client->queryCallDetailByCallId($queryCallDetailByCallIdRequest);
    }
}
$path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
if (file_exists($path)) {
    require_once $path;
}
Sample::main(array_slice($argv, 1));
// This file is auto-generated, don't edit it. Thanks.

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;

using Tea;
using Tea.Utils;


namespace AlibabaCloud.SDK.Sample
{
    public class Sample 
    {

        /**
         * 使用AK&SK初始化账号Client
         * @param accessKeyId
         * @param accessKeySecret
         * @return Client
         * @throws Exception
         */
        public static AlibabaCloud.SDK.Dyvmsapi20170525.Client CreateClient(string accessKeyId, string accessKeySecret)
        {
            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
            {
                // 您的AccessKey ID
                AccessKeyId = accessKeyId,
                // 您的AccessKey Secret
                AccessKeySecret = accessKeySecret,
            };
            // 访问的域名
            config.Endpoint = "dyvmsapi.aliyuncs.com";
            return new AlibabaCloud.SDK.Dyvmsapi20170525.Client(config);
        }

        public static void Main(string[] args)
        {
            AlibabaCloud.SDK.Dyvmsapi20170525.Client client = CreateClient("accessKeyId", "accessKeySecret");
            AlibabaCloud.SDK.Dyvmsapi20170525.Models.QueryCallDetailByCallIdRequest queryCallDetailByCallIdRequest = new AlibabaCloud.SDK.Dyvmsapi20170525.Models.QueryCallDetailByCallIdRequest
            {
                CallId = "100625930001^10019107****",
                ProdId = 11000000300004,
                QueryDate = 1577255564,
            };
            // 复制代码运行请自行打印 API 的返回值
            client.QueryCallDetailByCallId(queryCallDetailByCallIdRequest);
        }


    }
}
// This file is auto-generated, don't edit it
import Dyvmsapi20170525, * as $Dyvmsapi20170525 from '@alicloud/dyvmsapi20170525';
// 依赖的模块可通过下载工程中的模块依赖文件或右上角的获取 SDK 依赖信息查看
import OpenApi, * as $OpenApi from '@alicloud/openapi-client';
import * as $tea from '@alicloud/tea-typescript';


export default class Client {

  /**
   * 使用AK&SK初始化账号Client
   * @param accessKeyId
   * @param accessKeySecret
   * @return Client
   * @throws Exception
   */
  static createClient(accessKeyId: string, accessKeySecret: string): Dyvmsapi20170525 {
    let config = new $OpenApi.Config({
      // 您的AccessKey ID
      accessKeyId: accessKeyId,
      // 您的AccessKey Secret
      accessKeySecret: accessKeySecret,
    });
    // 访问的域名
    config.endpoint = "dyvmsapi.aliyuncs.com";
    return new Dyvmsapi20170525(config);
  }

  static async main(args: string[]): Promise<void> {
    let client = Client.createClient("accessKeyId", "accessKeySecret");
    let queryCallDetailByCallIdRequest = new $Dyvmsapi20170525.QueryCallDetailByCallIdRequest({
      callId: "100625930001^10019107****",
      prodId: 11000000300004,
      queryDate: 1577255564,
    });
    // 复制代码运行请自行打印 API 的返回值
    await client.queryCallDetailByCallId(queryCallDetailByCallIdRequest);
  }

}

Client.main(process.argv.slice(2));

执行结果

正常的执行结果如下所示。

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

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

阿里云首页 语音服务 相关技术圈