gpt4 book ai didi

node.js - 无法检索/下载实际录音 Media Twilio

转载 作者:太空宇宙 更新时间:2023-11-04 00:16:34 25 4
gpt4 key购买 nike

const Twilio = require('twilio');
const request = require('request');

const apiKeySid = 'SKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const apiKeySecret = 'your_api_key_secret';
const accountSid = 'ACb46a83261c60f3a45ce47eccac8a913d';
const client = new Twilio(apiKeySid, apiKeySecret, { accountSid:
accountSid });

const roomSid = 'RMXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const recordingSid = 'RTXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const uri = 'https://video.twilio.com/v1/' +
`Rooms/${roomSid}/` +
`Recordings/${recordingSid}` +
'/Media';
const response = client.request({ method: "POST", uri: uri });
const mediaLocation = JSON.parse(response.body).location;

request.get(mediaLocation, (err, res, media) => {
console.log(media);
});

我尝试检索记录的媒体,但这不起作用,并且在打印 response.body 时变得未定义。

最佳答案

这里是 Twilio 开发者布道者。

抱歉,这是我们文档中的一个错误。调用 client.request 是一个异步调用,并返回一个 Promise

试试这个:

client.request({ method: "GET", uri: uri }).then(response => {
const mediaLocation = JSON.parse(response.body).location;
request.get(mediaLocation, (err, res, media) => {
console.log(media);
});
});

我已经开始a pull request to get this back into the documentation here too .

关于node.js - 无法检索/下载实际录音 Media Twilio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46690939/

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