我只是按照说明进行设置和测试。我使用了Javascript API。当我尝试使用文档中提到的两个选项卡或两个窗口进行消息时,它无法正常工作。它会在sendMessage方法“undefined”时抛出错误。当我控制日志时,它会在html元素中输入正确的消息。
cds.twilio.com/v2/Streams:1 POST https://cds.twilio.com/v2/Streams 403 (Forbidden)
twilio-ip-messaging.min.js:198 IPMSG: failed to create session Object {status: 403, description: "Forbidden", body: "{"message":"Access forbidden","status":403}"}(anonymous function) @ twilio-ip-messaging.min.js:198
undefined:1 Uncaught (in promise) Object {status: 403, description: "Forbidden", body: "{"message":"Access forbidden","status":403}"}
undefined:1 Uncaught (in promise) Object {status: 403, description: "Forbidden", body: "{"message":"Access forbidden","status":403}"}
undefined:1 Uncaught (in promise) Object {status: 403, description: "Forbidden", body: "{"message":"Access forbidden","status":403}"}
twilio-ip-messaging.min.js:199 Twilsock connection closed by server []r._onSocketRejected @ twilio-ip-messaging.min.js:199d.create.callbacks.onsocketRejected @ twilio-ip-messaging.min.js:199e.doCallback @ twilio-ip-messaging.min.js:281e.afterThisEvent @ twilio-ip-messaging.min.js:281e.afterEvent @ twilio-ip-messaging.min.js:281transition @ twilio-ip-messaging.min.js:281(anonymous function) @ twilio-ip-messaging.min.js:281r.onmessage @ twilio-ip-messaging.min.js:199
答案 0 :(得分:2)
Twilio开发者传道者在这里。
首先,您需要使用您的生产帐户Sid才能使其生效。
Twilio test credentials only work on certain parts of the REST API
在服务器端生成令牌后,您需要将其发送到客户端并对客户端进行身份验证,如下所示:
accessManager = new Twilio.AccessManager(token);
messagingClient = new Twilio.IPMessaging.Client(accessManager);
看看IP Messaging quick start code to see an example of how it is done。 The full instructions for the quick start guide can be found here
让我知道这是否有帮助。