Twilio 队列的成员未定义
Members of Twilio Queue undefined
我在尝试访问队列成员时遇到错误。
我已经尝试了以下两种方法来将成员添加到队列中,以防我弄错了系统的工作方式。 (我开始使用Enqueue方法)
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Dial>
<Queue waitUrl="https://node.myserver.com:81/inbound/music">support</Queue>
</Dial>
</Response>
和
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Enqueue waitUrl="https://node.myserver.com:81/inbound/music">support</Enqueue>
</Response>
这两种方法似乎都适用于将呼叫添加到队列和播放等待音乐
我也检查过以确保队列的 SID 正确
运行代码
client.queues.list(function(err, data) {
data.queues.forEach(function(queue) {
console.log(queue.friendlyName + ": " + queue.sid);
});
});
给我结果
支持:QUxxxxxxxxxxxxxxxx6
然而,当我在队列中有呼叫等待并尝试使用 https://www.twilio.com/docs/api/rest/member
的 twilio API 页面中的示例提取数据时
client.queues('QUxxxxxxxxxxxxxxxx6').members.list(function(err, data) {
data.members.forEach(function(member) {
console.log(member.Position);
});
});
我收到以下错误
GET /inbound/call/agent 200 39.997 ms - 73
/var/www/tcc/node_modules/twilio/node_modules/q/q.js:126
throw e;
^
TypeError: Cannot call method 'forEach' of undefined
at /var/www/tcc/routes/index.js:348:20
at /var/www/tcc/node_modules/twilio/node_modules/q/q.js:1920:17
at flush (/var/www/tcc/node_modules/twilio/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
17 Feb 14:02:42 - [nodemon] app crashed - waiting for file changes before starting...
https://gist.github.com/StevenDStanton/f8c3d748e93466a7e4b8
var https = require('https');
var options = {
host: 'api.twilio.com',
port: 443,
path: '/2010-04-01/Accounts/' + sid + '/' + queuesid + '.json',
method: 'GET',
auth: sid + ":" + auth,
agent: false
};
var req = https.request(options, function(rex) {
rex.setEncoding('utf8');
rex.on('data', function (chunk) {
var obj = JSON.parse(chunk);
res.send(obj.current_size.toString());
});
});
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
req.end();
我在尝试访问队列成员时遇到错误。
我已经尝试了以下两种方法来将成员添加到队列中,以防我弄错了系统的工作方式。 (我开始使用Enqueue方法)
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Dial>
<Queue waitUrl="https://node.myserver.com:81/inbound/music">support</Queue>
</Dial>
</Response>
和
<?xml version="1.0" encoding="UTF-8" ?>
<Response>
<Enqueue waitUrl="https://node.myserver.com:81/inbound/music">support</Enqueue>
</Response>
这两种方法似乎都适用于将呼叫添加到队列和播放等待音乐
我也检查过以确保队列的 SID 正确
运行代码
client.queues.list(function(err, data) {
data.queues.forEach(function(queue) {
console.log(queue.friendlyName + ": " + queue.sid);
});
});
给我结果
支持:QUxxxxxxxxxxxxxxxx6
然而,当我在队列中有呼叫等待并尝试使用 https://www.twilio.com/docs/api/rest/member
的 twilio API 页面中的示例提取数据时 client.queues('QUxxxxxxxxxxxxxxxx6').members.list(function(err, data) {
data.members.forEach(function(member) {
console.log(member.Position);
});
});
我收到以下错误
GET /inbound/call/agent 200 39.997 ms - 73
/var/www/tcc/node_modules/twilio/node_modules/q/q.js:126
throw e;
^
TypeError: Cannot call method 'forEach' of undefined
at /var/www/tcc/routes/index.js:348:20
at /var/www/tcc/node_modules/twilio/node_modules/q/q.js:1920:17
at flush (/var/www/tcc/node_modules/twilio/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
17 Feb 14:02:42 - [nodemon] app crashed - waiting for file changes before starting...
https://gist.github.com/StevenDStanton/f8c3d748e93466a7e4b8
var https = require('https');
var options = {
host: 'api.twilio.com',
port: 443,
path: '/2010-04-01/Accounts/' + sid + '/' + queuesid + '.json',
method: 'GET',
auth: sid + ":" + auth,
agent: false
};
var req = https.request(options, function(rex) {
rex.setEncoding('utf8');
rex.on('data', function (chunk) {
var obj = JSON.parse(chunk);
res.send(obj.current_size.toString());
});
});
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
req.end();