Twilio IP 消息传递 API 不工作
Twilio IP Messaging API not working
我只是按照说明进行设置和测试。我用了JavascriptAPI。当我尝试使用文档中提到的两个选项卡或两个 windows 发送消息时,它不起作用。它在 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
这里是 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。
如果有帮助请告诉我。
我只是按照说明进行设置和测试。我用了JavascriptAPI。当我尝试使用文档中提到的两个选项卡或两个 windows 发送消息时,它不起作用。它在 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
这里是 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。
如果有帮助请告诉我。