简体   繁体   English

双向短信-发送/接收

[英]Two-Way SMS - Send/Receive

  1. I want to send receive SMS messages using SMS gateway. 我想使用SMS网关发送接收SMS消息。

  2. When sending message I am going to ask some question and reciever sould reply. 在发送消息时,我将要问一些问题,并得到答复。

  3. I need to add some unique id when sending the SMS, and get it back when receiving. 我需要在发送短信时添加一些唯一的ID,并在接收时将其取回。

I know there is a way to do that, like ICQ and Google vois 2 way sms. 我知道有办法做到这一点,例如ICQ和Google vois 2种方式的短信。 The receiver return the message to the same number, but only the sender get it back. 接收者将消息返回到相同的号码,但只有发送者将其取回。

Can someone help with this? 有人可以帮忙吗?

Thanks, Lior 谢谢,Lior

Almost all SMS gateways allow you to send and receive messages. 几乎所有的SMS网关都允许您发送和接收消息。 The most common method for sending messages is via some sort of HTTP API (SOAP, REST, RPC). 发送消息的最常见方法是通过某种HTTP API(SOAP,REST,RPC)。 For example, to send a message using Twilio (where I work) you would make a POST request to our API with three parameters: To (the recipient), From (your Twilio number), and Body (what to include in the message). 例如,使用发送邮件Twilio (我工作的地方),你会作出一个POST请求我们的API有三个参数: To (收件人), From (你的Twilio号)和Body (什么消息中包括) 。 Many other gateways use similar methods. 许多其他网关使用类似的方法。

Due to limitations of the SMS system worldwide, there is no way to uniquely identify messages. 由于全球SMS系统的局限性,因此无法唯一标识消息。 This means that unless the recipient of a message manually includes an identifier there is no way to associate a reply with the original message outside of matching the sender and recipients phone numbers. 这意味着,除非消息的收件人手动包含标识符,否则在匹配发送方和收件人的电话号码之外,无法将回复与原始消息相关联。 This can make it tricky to handle cases where there are multiple outstanding queries to a single recipient. 这可能会很难处理单个收件人有多个未完成查询的情况。 There are a couple strategies you can use to get around this limitation. 您可以使用几种策略来解决此限制。

  1. Request unique response tokens - For each query sent to a recipient, require the response to be unique to that query. 请求唯一的响应令牌 -对于发送给收件人的每个查询,要求该响应对于该查询是唯一的。 For instance, on the first message use something like, "To confirm, respond with A1" and on subsequent outstanding queries use a different unique response. 例如,在第一个消息上使用“确认,用A1响应”之类的内容,在后续未完成的查询上使用不同的唯一响应。

  2. Use different 'From' phone numbers - For each query sent to a recipient, send from a different number. 使用不同的“发件人”电话号码 -对于发送给收件人的每个查询,请使用不同的号码发送。 Then you can match the response to the phone number responded to. 然后,您可以将响应与响应的电话号码进行匹配。 This is not an optimal system in many cases since you need more phone numbers and users could receive messages from many different numbers resulting in confusion. 在许多情况下,这不是理想的系统,因为您需要更多的电话号码,并且用户可能会收到来自许多不同号码的消息,从而造成混乱。

  3. Expire outstanding queries - If responses to each query aren't important, just assume they're responding to the most recent, or prompt them for clarification after a response. 使未完成的查询过期 -如果对每个查询的响应都不重要,则只需假定它们正在响应最近的查询,或在响应后提示他们进行澄清。

In regards to receiving messages, most gateways will notify you via HTTP. 关于接收消息,大多数网关都会通过HTTP通知您。 As an example, when a message comes into your Twilio number, we make a POST request to a URL that you specify with the To , From and Body parameters included. 例如,当一条消息进入您的Twilio号码时,我们将向您指定的URL发出POST请求,该URL包含ToFromBody参数。 You handle this like any other form submission in your application. 您可以像处理应用程序中的其他任何表单提交一样处理此问题。 Other gateways use similar methods, but I can't attest to the details. 其他网关也使用类似的方法,但是我无法证明细节。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM