dongyou7292 2012-12-19 00:29
浏览 53

如何通过服务器websocket将twilio sms传递给客户端

I am trying to setup my server so that I can have someone contact me through a chatbox on our website. Since I won't be there at all times to monitor the chats, I am trying to setup a system where the chat is routed through a websocket to my server (using PHP-Websockets) which is then sent to my phone via sms. This is all working correctly. I am having trouble wrapping my head around how my response can get back to the client side. When I respond to a text, Twilio will access any page that I specify with the sms message as a post variable. How can I pass this post message to my websocket (which is already running) where it can then send the message back to the client? Thanks for your help guys

  • 写回答

1条回答 默认 最新

  • doubailian4459 2012-12-19 08:12
    关注

    Twilio communicates with your application via a WebHook call (HTTP request) when it receives your SMS.

    Since PHP-WebSockets is running as a standalone process, and not as part of an existing web stack (e.g. Apache) then you'll need to have a few components in your setup:

    1. PHP-WebSocket
    2. Web server - serving up your HTML, CSS etc and also interacted with by the Twilio WebHook
    3. A way for 1. and 2. to interact. This is usually achieved through some sort of message queue

    Here's a sequence diagram that details the communication between the various components in your setup, as I see it:

    Hopefully that clarifies the communication from Twilio, your web server, your WebSocket server and your client.

    If this seems overly complicated then you could remove the requirement to have the WebSocket server and message queue by using a hosted service such as Pusher, who I work for. If that is the case then this using Pusher & Twilio tutorial should be useful. One of the main benefits here is that you can continue to think in terms of request and response, rather than having to think about cross component communications through message queues.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起