【问题标题】:can't get channel by a unqiue name twillio programmabale chat node js无法通过唯一名称获取频道 twilio 可编程聊天节点 js
【发布时间】:2020-04-21 18:23:30
【问题描述】:

//这是我通过唯一名称获取频道的代码。它没有给我任何回应

client.chat.services(serviceSid)
        .channels({uniqueName:'demo'})
        .fetch()
        .then(channel => console.log(channel));

// 这是通道的表单 sid,它正在工作

client.chat.services(serviceSid)
        .channels('XXXXX')
        .fetch
        .then(channels=>  console.log(channel));

反应是

{
  sid: 'CH...................b1e',
  accountSid: 'AC...................b71735f',
  serviceSid: 'IS..................caa8',
  friendlyName: 'demo',
  uniqueName: 'demo',
  attributes: '{}',
  type: 'public',
  dat2020-04-21T16:54:52.000Z,
  dateUpdated: 2020-04-21T16:54:52.000Z,
  createdBy: 'system',
  membersCount: 0,
  messagesCount: 0,
  url: }

chaneel resource 中写的文档中 获取 Channel 资源时,{Sid} 值可以是要获取的 Channel 资源的 sid 或 unique_name。 我将如何检索请回答.. 我需要在 3 天内完成这个项目...

【问题讨论】:

  • 通过唯一名称代码获取频道没有给我任何回应,你可以看到有一个频道 unqiuename demo 。 asd 响应也在那里
  • 您最好将信息的敏感部分注释掉。我记得我第一次看到这个帖子时,整个事情都暴露了。

标签: javascript node.js twilio twilio-api twilio-programmable-chat


【解决方案1】:

https://www.twilio.com/docs/chat/rest/channel-resource#fetch-a-channel-resource 我正在查看来自 twilio 的这些文档,并且从他们的示例中,我会尝试编写如下代码:

client.chat.services(serviceSid)
           .channels('demo')
           .fetch()
           .then(channel => console.log(channel));

无需传递对象,只需传递unique_name 的字符串即可获取您要查找的频道。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-22
    • 1970-01-01
    • 2019-05-24
    • 1970-01-01
    • 2020-07-10
    • 2021-03-02
    • 2018-10-10
    相关资源
    最近更新 更多