拨打子账号的twilio号码的正确方法是什么?

问题描述 投票:0回答:1

呼叫子账号的twilio号码的正确方法是什么?这是我目前的方法。

        async function placeCall(context, event, callback) {
        var to = event.Called;
        var from = event.From;
        var toClient = "";
        var blockListArr = [];
        let blocked = true;
        let donotDist = false;
        var apiKeyDb = "calles's api key";
        var apiSecretDb = "callee's api key secret";

        console.log("event : " + JSON.stringify(event));

        var url = "https://demo.twilio.com/docs/voice.xml";
        console.log(url);
        const accountSid = context.ACCOUNT_SID;

        const client = require('twilio')(apiKeyDb, apiSecretDb, {
            accountSid: event.AccountSid
        });
        if (isNumber(to)) {
            call = await client.api.calls.create({
                url: url,
                to: to,
                from: from,
            });
            console.log(call.sid)
            return callback(null, JSON.stringify(call));
        }
    }
    exports.handler = function(context, event, callback) {
        var p1 = new Promise(function(resolve, reject) {
            resolve(placeCall(context, event, callback));
        });

        p1.then(function(value) {
            console.log("val : " + value); // "Success!"
            throw new Error('error');
        }).catch(function(e) {
            console.error("error : " + e.message);
            console.error("error : " + e.status);
        });
    };

    function isNumber(to) {
        if (to.length == 1) {
            if (!isNaN(to)) {
                return true;
            }
        } else if (String(to).charAt(0) == '+') {
            number = to.substring(1);
            if (!isNaN(number)) {
                return true;
            }
        } else {
            if (!isNaN(to)) {
                return true;
            }
        }
        return false;
    }

但我收到的是

错误。所提供的源电话号码,+88016855548...,尚未对您的账户进行验证。您只能用您已经验证过的或从Twilio购买的电话号码拨打电话。

在不需要验证的情况下,怎么会有人能够拨打子账号的twilio号码?可以是其他子账号的twilio号码,也可以是外面的twilio号码(真实电话号码)。

twilio twilio-api twilio-voice twilio-node
1个回答
0
投票

你必须在你要调用的账户中使用验证过的CallerID。From 或您拨打的账户中的Twilio号码。From 作为主叫人ID。

这篇文章介绍了如何在子账户中批量添加验证过的CallerID。当您知道CallerID时,这将会有效,但它不会对欺骗您的子账户的呼入PSTN号码有效。

规模化验证来电ID

© www.soinside.com 2019 - 2024. All rights reserved.