收到短信后如何发送回复短信?
我有一个应用程序,需要从一个用户向另一个用户发送短信。收到此短信后,它会发回一条回复短信。我开发了一个代码,但问题是它陷入了从一个用户向另一个用户一次又一次发送的循环。对于例如,如果用户 1 向用户 2 发送一些短信,则一条短信会自动发送给用户 1,而用户 1 又会自动再次向用户 2 发送短信,这样反复进行。我怎样才能避免这种情况呢?我只需从用户 2 向用户 1 发送一次回复短信,然后就不会返回短信。请帮我解决此代码。
这是我的代码:
提前致谢。
I have an application which requires sending sms from one user to another.On receiving this sms it sends back a reply sms.I have developed a code but the problem is it goes in aloop of sending again and again from one user to another.For example if user 1 sends some sms to user 2,then a sms is automatically sent to user 1 which in turn automatically sends sms to user 2 again and this goes again and again.How can I avoid that? I have to send the reply sms only once from user 2 to user 1 and then no return sms.Please help me with this code.
Here is my code:
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您知道自动短信回复将包含的确切文本,难道您不能在发送回复的块周围放置一个条件吗?
编辑:如果消息是动态的(根据您的评论,这似乎是必需的),那么您可以确保所有自动回复都以特殊的字符串标记开头,该标记将它们标识为自动回复。这样,如果您收到以您的令牌开头的消息,您就知道不需要回复:
If you know the exact text that the automated SMS reply will contain, can't you just put a condition around the block that sends the reply?
edit: if the message is dynamic (which it seems that it needs to be, based on your comments) then you could ensure that all automatic replies start with a special string token which identifies them as an automatic reply. This way, if you receive a message that starts with your token, you know you don't need to reply: