本示例介绍了如何调用CancelCall取消ClickToDial接口发起的呼叫。

功能介绍

点击呼叫是指通过调用语音服务接口,通过语音服务分配的号码分别向主叫、被叫发起呼叫,双方接通后建立起正常通话,通话双方显示的号码均为语音服务平台号码。常用于企业办公电话等,例如钉钉办公电话。通过点击呼叫接口,可隐藏通话双方真实号码,同时平台可留存双方通话记录。

准备工作

调用该API实现取消点击呼叫功能之前,您需要成功调用ClickToDial实现点击呼叫,并获取CallId。

代码示例

接口详情请参见CancelCall

如果您需要进行调试请参考使用OpenAPI Explorer
// This file is auto-generated, don't edit it. Thanks.
package com.aliyun;

import com.aliyun.tea.*;


public class Client {

    /**
     * 使用AK&SK初始化账号Client
     * @param accessKeyId
     * @param accessKeySecret
     * @param regionId
     * @return Client
     * @throws Exception
     */
    public static com.aliyun.dyvmsapi20170525.Client createClient(String accessKeyId, String accessKeySecret, String regionId) throws Exception {
        com.aliyun.tearpc.models.Config config = new com.aliyun.tearpc.models.Config();
        // 您的AccessKey ID
        config.accessKeyId = accessKeyId;
        // 您的AccessKey Secret
        config.accessKeySecret = accessKeySecret;
        // 您的可用区ID
        config.regionId = regionId;
        return new com.aliyun.dyvmsapi20170525.Client(config);
    }

    /**
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        com.aliyun.dyvmsapi20170525.Client client = Client.createClient("accessKeyId", "accessKeySecret", "regionId");
        com.aliyun.dyvmsapi20170525.models.CancelCallRequest request = com.aliyun.dyvmsapi20170525.models.CancelCallRequest.build(TeaConverter.buildMap(
            // 通话的唯一回执ID。
            new TeaPair("callId", "117059405036^10385912xx")
        ));
        // 发起请求
        com.aliyun.dyvmsapi20170525.models.CancelCallResponse response = client.cancelCall(request);
    }
}
# This file is auto-generated, don't edit it. Thanks.
from alibabacloud_dyvmsapi20170525.client import Client as DyvmsapiClientClient
from alibabacloud_tea_rpc import models as _rpc_models
from alibabacloud_dyvmsapi20170525 import models as dyvmsapi_client_models


class Client:

    @staticmethod
    def create_client(access_key_id, access_key_secret, region_id):
        """
        使用AK&SK初始化账号Client

        :type access_key_id: str
        :param access_key_id:

        :type access_key_secret: str
        :param access_key_secret:

        :type region_id: str
        :param region_id:

        :return: Client
        @throws Exception
        """
        config = _rpc_models.Config(

        )
        # 您的AccessKey ID
        config.access_key_id = access_key_id
        # 您的AccessKey Secret
        config.access_key_secret = access_key_secret
        # 您的可用区ID
        config.region_id = region_id
        return DyvmsapiClientClient(config)

    @staticmethod
    def main(args):
        """

        :param args:
        @throws Exception
        """
        client = create_client("accessKeyId", "accessKeySecret", "regionId")
        request = dyvmsapi_client_models.CancelCallRequest(
            call_id="117059405036^10385912xx"
        )
        # 发起请求
        response = client.cancel_call(request)
    def __init__(self):
        pass
// This file is auto-generated, don't edit it. Thanks.
package client

import (
  dyvmsapiclient  "github.com/alibabacloud-go/dyvmsapi-20170525/client"
  rpc  "github.com/alibabacloud-go/tea-rpc/client"
  "github.com/alibabacloud-go/tea/tea"
)


/**
 * 使用AK&SK初始化账号Client
 * @param accessKeyId
 * @param accessKeySecret
 * @param regionId
 * @return Client
 * @throws Exception
 */
func CreateClient (accessKeyId *string, accessKeySecret *string, regionId *string) (_result *dyvmsapiclient.Client) {
  config := &rpc.Config{}
  // 您的AccessKey ID
  config.AccessKeyId = accessKeyId
  // 您的AccessKey Secret
  config.AccessKeySecret = accessKeySecret
  // 您的可用区ID
  config.RegionId = regionId
  _result = &dyvmsapiclient.Client{}
  _result, _err = dyvmsapiclient.NewClient(config)
  return _result
}

/**
 * @param args
 * @throws Exception
 */
func Main (args []*string) (_err error) {
  client := CreateClient(tea.String("accessKeyId"), tea.String("accessKeySecret"), tea.String("regionId"))
  request := &dyvmsapiclient.CancelCallRequest{
    // 通话的唯一回执ID。
    CallId: tea.String("117059405036^10385912xx"),
  }
  // 发起请求
  response, _err := client.CancelCall(request)
  if _err != nil {
    return _err
  }

  return _err
}
<?php

// This file is auto-generated, don't edit it. Thanks.
namespace DarabonbaSDK;

use AlibabaCloud\SDK\Dyvmsapi\V20170525\Dyvmsapi;

use AlibabaCloud\Tea\Rpc\Rpc\Config;
use AlibabaCloud\SDK\Dyvmsapi\V20170525\Models\CancelCallRequest;
use AlibabaCloud\SDK\Dyvmsapi\V20170525\Models\CancelCallResponse;

class Client {

    /**
     * 使用AK&SK初始化账号Client
     * @param string $accessKeyId
     * @param string $accessKeySecret
     * @param string $regionId
     * @return Dyvmsapi Client
     */
    public static function createClient($accessKeyId, $accessKeySecret, $regionId){
        $config = new Config([]);
        // 您的AccessKey ID
        $config->accessKeyId = $accessKeyId;
        // 您的AccessKey Secret
        $config->accessKeySecret = $accessKeySecret;
        // 您的可用区ID
        $config->regionId = $regionId;
        return new Dyvmsapi($config);
    }

    /**
     * @param array $args
     * @return void
     */
    public static function main($args){
        $client = self::createClient("accessKeyId", "accessKeySecret", "regionId");
        $request = new CancelCallRequest([
            // 通话的唯一回执ID。
            "callId" => "117059405036^10385912xx"
        ]);
        // 发起请求
        $response = $client->cancelCall($request);
    }
}
// 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 com.aliyun
{
    public class Client 
    {

        /**
         * 使用AK&SK初始化账号Client
         * @param accessKeyId
         * @param accessKeySecret
         * @param regionId
         * @return Client
         * @throws Exception
         */
        public static AlibabaCloud.SDK.Dyvmsapi20170525.Client CreateClient(string accessKeyId, string accessKeySecret, string regionId)
        {
            AlibabaCloud.RPCClient.Models.Config config = new AlibabaCloud.RPCClient.Models.Config();
            // 您的AccessKey ID
            config.AccessKeyId = accessKeyId;
            // 您的AccessKey Secret
            config.AccessKeySecret = accessKeySecret;
            // 您的可用区ID
            config.RegionId = regionId;
            return new AlibabaCloud.SDK.Dyvmsapi20170525.Client(config);
        }

        /**
         * @param args
         * @throws Exception
         */
        public static void Main(string[] args)
        {
            AlibabaCloud.SDK.Dyvmsapi20170525.Client client = Client.CreateClient("accessKeyId", "accessKeySecret", "regionId");
            AlibabaCloud.SDK.Dyvmsapi20170525.Models.CancelCallRequest request = new AlibabaCloud.SDK.Dyvmsapi20170525.Models.CancelCallRequest
            {
                // 通话的唯一回执ID。
                CallId = "117059405036^10385912xx",
            };
            // 发起请求
            AlibabaCloud.SDK.Dyvmsapi20170525.Models.CancelCallResponse response = client.CancelCall(request);
        }


    }
}
// This file is auto-generated, don't edit it
import DyvmsapiClient, * as $DyvmsapiClient from '@alicloud/dyvmsapi20170525';
import RPC, * as $RPC from '@alicloud/rpc-client';
import * as $tea from '@alicloud/tea-typescript';


export default class Client {

  /**
   * 使用AK&SK初始化账号Client
   * @param accessKeyId
   * @param accessKeySecret
   * @param regionId
   * @return Client
   * @throws Exception
   */
  static createClient(accessKeyId: string, accessKeySecret: string, regionId: string): DyvmsapiClient {
    let config = new $RPC.Config({ });
    // 您的AccessKey ID
    config.accessKeyId = accessKeyId;
    // 您的AccessKey Secret
    config.accessKeySecret = accessKeySecret;
    // 您的可用区ID
    config.regionId = regionId;
    return new DyvmsapiClient(config);
  }

  /**
   * @param args
   * @throws Exception
   */
  static async main(args: string[]): Promise<void> {
    let client = Client.createClient("accessKeyId", "accessKeySecret", "regionId");
    let request = new $DyvmsapiClient.CancelCallRequest({
      // 通话的唯一回执ID。
      callId: "117059405036^10385912xx",
    });
    // 发起请求
    let response = await client.cancelCall(request);
  }

}

执行结果

正常的结果如下所示:
{
    "Status":"true",
    "Message":"OK",
    "RequestId":"D9CB3933-9FE3-4870-BA8E-2BEE91B69D23",
    "Code":"OK"
}

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