发起语音双呼

本文为您介绍如何调用ClickToDial接口发起语音双呼。

功能介绍

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

前提条件

代码示例

本示例展示了调用ClickToDial接口发起语音双呼。接口详情,请参见ClickToDial

如果您需要进行调试,推荐使用阿里云OpenAPI 开发者门户

// This file is auto-generated, don't edit it. Thanks.
package com.aliyun:dyvmsapi20170525:*;
import com.aliyun.tea.*;
public class Client {
    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();
        config.accessKeyId = accessKeyId;
        config.accessKeySecret = accessKeySecret;
        config.regionId = regionId;
    }
    public static void main(String[] args) throws Exception {
        com.aliyun.dyvmsapi20170525.Client client = Client.createClient("accessKeyId", "accessKeySecret", "regionId");
        com.aliyun.dyvmsapi20170525.models.ClickToDialRequest request = com.aliyun.dyvmsapi20170525.models.ClickToDialRequest.build(TeaConverter.buildMap(
            new TeaPair("callerShowNumber", "123xxxx"),
            new TeaPair("callerNumber", "1575xxxx"),
            new TeaPair("calledShowNumber", "12xxxx"),
            new TeaPair("calledNumber", "1885xxxx")
        ));
        com.aliyun.dyvmsapi20170525.models.ClickToDialResponse response = client.clickToDial(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
        """
        config = _rpc_models.Config(
        )
        config.access_key_id = access_key_id
        config.access_key_secret = access_key_secret
        config.region_id = region_id
    @staticmethod
    def main(args):
        client = create_client("accessKeyId", "accessKeySecret", "regionId")
        request = dyvmsapi_client_models.ClickToDialRequest(
            caller_show_number="123xxxx",
            caller_number="1575xxxx",
            called_show_number="12xxxx",
            called_number="1885xxxx"
        )
        response = client.click_to_dial(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  
func CreateClient (accessKeyId *string, accessKeySecret *string, regionId *string) (_result *dyvmsapiclient.Client) {
  config := &rpc.Config{}
  config.AccessKeyId = accessKeyId
  config.AccessKeySecret = accessKeySecret
  config.RegionId = regionId
  return _result
}
func Main (args []*string) (_err error) {
  client := CreateClient(tea.String("accessKeyId"), tea.String("accessKeySecret"), tea.String("regionId"))
  request := &dyvmsapiclient.ClickToDialRequest{
    CallerShowNumber: tea.String("123xxxx"),
    CallerNumber: tea.String("1575xxxx"),
    CalledShowNumber: tea.String("12xxxx"),
    CalledNumber: tea.String("1885xxxx"),
  }
  response, _err := client.ClickToDial(request)
  if _err != nil {
    return _err
  }
  return _err
}
<?php
// This file is auto-generated, don't edit it. Thanks.
namespace alibabacloud/dyvmsapi-20170525:^0\1\0;
use AlibabaCloud\SDK\Dyvmsapi\V20170525\Dyvmsapi;
use AlibabaCloud\Tea\Rpc\Rpc\Config;
use AlibabaCloud\SDK\Dyvmsapi\V20170525\Models\ClickToDialRequest;
use AlibabaCloud\SDK\Dyvmsapi\V20170525\Models\ClickToDialResponse;
class Client {
    /**
     * 使用AK&SK初始化账号Client
     * @param string $accessKeyId
     * @param string $accessKeySecret
     * @param string $regionId
     * @return Dyvmsapi
     */
    public static function createClient($accessKeyId, $accessKeySecret, $regionId){
        $config = new Config([]);
        $config->accessKeyId = $accessKeyId;
        $config->accessKeySecret = $accessKeySecret;
        $config->regionId = $regionId;
    }
    /**
     * @param array $args
     * @return void
     */
    public static function main($args){
        $client = self::createClient("accessKeyId", "accessKeySecret", "regionId");
        $request = new ClickToDialRequest([
            "callerShowNumber" => "123xxxx",
            "callerNumber" => "1575xxxx",
            "calledShowNumber" => "12xxxx",
            "calledNumber" => "1885xxxx"
        ]);
        $response = $client->clickToDial($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 AlibabaCloud.SDK.Dyvmsapi20170525:*
{
    public class Client 
    {
        // 使用AK&SK初始化账号Client  
        public static AlibabaCloud.SDK.Dyvmsapi20170525.Client CreateClient(string accessKeyId, string accessKeySecret, string regionId)
        {
            AlibabaCloud.RPCClient.Models.Config config = new AlibabaCloud.RPCClient.Models.Config();
            config.AccessKeyId = accessKeyId;
            config.AccessKeySecret = accessKeySecret;
            config.RegionId = regionId;
        }
        public static void Main(string[] args)
        {
            AlibabaCloud.SDK.Dyvmsapi20170525.Client client = Client.CreateClient("accessKeyId", "accessKeySecret", "regionId");
            AlibabaCloud.SDK.Dyvmsapi20170525.Models.ClickToDialRequest request = new AlibabaCloud.SDK.Dyvmsapi20170525.Models.ClickToDialRequest
            {
                CallerShowNumber = "123xxxx",
                CallerNumber = "1575xxxx",
                CalledShowNumber = "12xxxx",
                CalledNumber = "1885xxxx",
            };
            AlibabaCloud.SDK.Dyvmsapi20170525.Models.ClickToDialResponse response = client.ClickToDial(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  
  static createClient(accessKeyId: string, accessKeySecret: string, regionId: string): DyvmsapiClient {
    let config = new $RPC.Config({ });
    config.accessKeyId = accessKeyId;
    config.accessKeySecret = accessKeySecret;
    config.regionId = regionId;
  }
  static async main(args: string[]): Promise<void> {
    let client = Client.createClient("accessKeyId", "accessKeySecret", "regionId");
    let request = new $DyvmsapiClient.ClickToDialRequest({
      callerShowNumber: "123xxxx",
      callerNumber: "1575xxxx",
      calledShowNumber: "12xxxx",
      calledNumber: "1885xxxx",
    });
    let response = await client.clickToDial(request);
  }
}

执行结果

正常返回结果如下所示:

{
  "Message": "OK",
  "RequestId": "4ABF7FB6-449C-4624-8CC6-9AAE3684****",
  "Code": "OK",
  "CallId": "1187209624900105518****"
}

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

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