gpt4 book ai didi

node.js - 类型错误 : Cannot read property 'isTTY' of undefined

转载 作者:太空宇宙 更新时间:2023-11-03 22:08:13 25 4
gpt4 key购买 nike

const accountSid = 'account_sid';
const authToken = 'auth_token';

const client = require('twilio')(accountSid, authToken);

client.messages
.create({
to: '+94716220786',
from: '+13022519234',
body: 'Your verification code is ' + Math.floor(1000 + Math.random() *
9000)
})
.then(message => console.log(message.sid));
console.log('receive');
console.log(Math.floor(1000 + Math.random() * 9000));

我正在尝试使用 twilio 发送短信。我已经在我的 Angular 项目中安装了 twilio 最新版本。

But when the project runs, it says that "Cannot read property 'isTTY' of undefined"

最佳答案

这里是 Twilio 开发者布道者。

Twilio Node library不适合在客户端使用。主要是因为这会暴露您的凭据,然后攻击者就可以使用您的帐户。 JavaScript 在客户端也是可编辑的,因此发送验证码很容易被不道德的用户编辑和滥用。

相反,您需要构建一个服务器端组件来向客户端发出请求。如果您正在构建电话验证,那么我可以建议您遵循此tutorial on account verification with Twilio .

如果您想从更基础的开始,那么我推荐 quick start guide to sending and receiving SMS with Twilio in Node .

关于node.js - 类型错误 : Cannot read property 'isTTY' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50056009/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com