使用 AWS Lambda (nodejs) 获取 twilio 使用数据
Get twilio usage data using an AWS Lambda (nodejs)
我希望能够从 AWS Lambda 函数中获取来自 Twilio 的使用数据。我正在关注 twilio 的 REST API page 上的示例,但没有取得任何成功。我正在使用 Twilio 的 Node Helper Library 版本 3。下面是我在处理程序中的代码:
'use strict';
exports.handler = async(request, context) => {
const accountSid = 'my account sid';
const authToken = 'my auth token';
const client = require('twilio')(accountSid, authToken);
client.usage.records.today.each(record => console.log(record.count));
};
Lambda "feels" 至少在尝试从 Twilio 获取数据。它运行约 10 秒后结束,没有任何错误。但是我从来没有收到 'here' 消息。
提前致谢,斯科特
这是我的 Lambda 代码:
exports.handler = (event, context, callback) => {
// Your Account SID from www.twilio.com/console
const accountSid = process.env.TWILIO_ACCOUNT_SID;
// Your Auth Token from www.twilio.com/console
const authToken = process.env.TWILIO_AUTH_TOKEN;
// Import Twilio's Node Helper library
// Create an authenticated Twilio Client instance
const client = require('twilio')(accountSid, authToken);
client.usage.records.lastMonth.each(record => console.log('here'));
};
这就是我在 运行 函数(状态:成功)后的 "Function code" 部分中看到的内容。
我希望能够从 AWS Lambda 函数中获取来自 Twilio 的使用数据。我正在关注 twilio 的 REST API page 上的示例,但没有取得任何成功。我正在使用 Twilio 的 Node Helper Library 版本 3。下面是我在处理程序中的代码:
'use strict';
exports.handler = async(request, context) => {
const accountSid = 'my account sid';
const authToken = 'my auth token';
const client = require('twilio')(accountSid, authToken);
client.usage.records.today.each(record => console.log(record.count));
};
Lambda "feels" 至少在尝试从 Twilio 获取数据。它运行约 10 秒后结束,没有任何错误。但是我从来没有收到 'here' 消息。
提前致谢,斯科特
这是我的 Lambda 代码:
exports.handler = (event, context, callback) => {
// Your Account SID from www.twilio.com/console
const accountSid = process.env.TWILIO_ACCOUNT_SID;
// Your Auth Token from www.twilio.com/console
const authToken = process.env.TWILIO_AUTH_TOKEN;
// Import Twilio's Node Helper library
// Create an authenticated Twilio Client instance
const client = require('twilio')(accountSid, authToken);
client.usage.records.lastMonth.each(record => console.log('here'));
};
这就是我在 运行 函数(状态:成功)后的 "Function code" 部分中看到的内容。