如何在node.js中从Twilio检索来电者和运营商?



我在使用 twilio-api for node 时遇到问题。

我写了这段代码:

let typeArray = ['caller-name','carrier'];
this.client.phoneNumbers(phoneNumberToCheck).get({
type: typeArray
}, (error, number) =>  {
// working on the number data results
// ...
});

问题是我没有得到它们中的任何一个(运营商/呼叫者名称( - 尽管将数组传递给参数"type"是在其他语言(php,c#...(中执行此操作的方法,但它在节点上不起作用.js,相反,我得到这个:

// -> get 
{
"caller_name":null,
"country_code":"US",
"phone_number":"+123456789",
"national_format":"(248) 123-456",
"carrier":null,
"add_ons":null,
"url":"https://lookups.twilio.com/v1/PhoneNumbers/+123456789",
"callerName":null,
"countryCode":"US",
"phoneNumber":"+123456789",
"nationalFormat":"(248) 123-456",
"addOns":null
}

注意:如果我单独发送每个(仅运营商或仅呼叫者姓名( - 我会获得每个的部分信息。

如何在 Node.js 中的一个请求中同时获得两者?

Twilio开发者布道者在这里。

您应该以这种方式在 Node 中调用 Lookups API:

client.lookups.phoneNumbers.get(phoneNumber)
.fetch({
type: ['carrier', 'caller-name']
},
function(err, result) {
// do something
}
)

在查找文档中,Node.js文档中的文档有点不足,我将向团队提出这一点。

最新更新