[英]Twilio: How to buy number through nodejs?
I need to buy twilio numbers through nodejs.我需要通过 nodejs 购买 twilio 数字。 I could not find any answer regarding that.
我找不到任何关于此的答案。 Is it really possible to buy twilio number through node.js ?
真的可以通过 node.js 购买 twilio number 吗?
I really appreciate any guidance.我真的很感激任何指导。
Thanks谢谢
Here is the link to the relevant documentation.这是相关文档的链接。
IncomingPhoneNumber resource 来电号码资源
Reference the Node.js code sample: "Provision a Phone Number"参考 Node.js 代码示例:“Provision a Phone Number”
You can get a list of available numbers using another API:您可以使用另一个 API 获取可用号码列表:
AvailablePhoneNumber resource 可用电话号码资源
and the associated sub-resources on that page (Local, Toll Free, Mobile).以及该页面上的相关子资源(本地、免费、移动)。
See Alan's response for Twilio's docs.请参阅 Alan 对 Twilio 文档的回复。 In short:
简而言之:
TWILIO_ACCOUNT_SID=AC...
TWILIO_AUTH_TOKEN=4f...
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = require('twilio')(accountSid, authToken);
client.availablePhoneNumbers('CA')
.local
.list({ areaCode: 604, limit: 20 })
.then(local => local.forEach(l => console.log(l.friendlyName)));
CA is the country code and 604 is the area code
CA是国家代码,604是区号
You will get a list of available phone numbers based on the country code and area code you provided in the get_available_numbers.js
您将根据您在 get_available_numbers.js 中提供的国家/地区代码和区号获得可用电话号码列表
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = require('twilio')(accountSid, authToken);
client.incomingPhoneNumbers
.create({ phoneNumber: '+16047574779' })
.then(incoming_phone_number => console.log(incoming_phone_number.sid));
Where +16047574779 is one of the phone numbers from the list you got after running "node get_available_number.js"
其中 +16047574779 是您在运行“node get_available_number.js”后获得的列表中的电话号码之一
You will get a response with information about your provisioned phone number
您将收到有关您提供的电话号码信息的回复
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.