如何整合SMS& EMAIL提醒我的play2.0框架Web应用程序。 [英] how to integrate SMS & EMAIL Reminders in my play2.0 framework web application.

查看:131
本文介绍了如何整合SMS& EMAIL提醒我的play2.0框架Web应用程序。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在play2.0框架中创建一个Web应用程序。在此应用程序中,我需要通过从数据库获取详细信息,将SMS和EMAIL提醒程序集成在一个特定的日期和时间内发送短信和电子邮件。
那么有没有任何免费API或调度程序或Web服务或应用程序?
如果有任何的话请告诉我如何使用?
提前感谢。

解决方案

在Play 1.x中,这可以通过Jobs的概念实现。在Play 2.x中,使用Akka的调度程序来完成异步执行代码。



所以,从你的用例来看,你可能想要一个运行每一个分钟(让我们假设30为示例),这将转到数据库,并检查是否需要发送任何电子邮件。从这里,你可以打电话给你的网络服务发送短信和电子邮件。

  Akka.system()。scheduler()。 scheduleOnce(
Duration.create(30,TimeUnit.MINUTES),
new Runnable(){
public void run(){
//检查需要提醒的数据库发送
//发送电子邮件
//发送短信
}
}
);对于发送短信的服务,您可以查看Twilio(



< /www.twilio.com/api/smsrel =nofollow> http://www.twilio.com/api/sms
)。您只需要使用 play.libs.WS 类集成。



电子邮件是谜题的微不足道的一部分,已经被回答了很多次,所以我不会详细介绍。


I'm creating a web application in play2.0 framework.In this application i need to integrate SMS and EMAIL reminder to send sms and email on a particular date and time by getting the details from database. For that is there any Free API's or scheduler or web service or applications ? If there is any then kindly let me know how to use ? thanks in advance.

解决方案

In Play 1.x, this would have been achieve with the concept of Jobs. In Play 2.x, asynchronous execution of code is done using Akka's scheduler.

So, from your use case, you will probably want to have a job that runs every few minutes (lets assume 30 for the example), that goes off to the database and checks to see if any emails need to be sent. From here, you can then call your web service to send SMS and Email.

Akka.system().scheduler().scheduleOnce(
  Duration.create(30, TimeUnit.MINUTES),
  new Runnable() {
    public void run() {
      // check database for reminders that need to be sent
      // send email
      // send SMS
    }
  }
); 

As for services for sending SMS, you could check out Twilio ( http://www.twilio.com/api/sms ). You just need to integrate using the play.libs.WS class.

Email is a trivial part of the puzzle, and has been answered many times over already, so I won't go into detail on that.

这篇关于如何整合SMS&amp; EMAIL提醒我的play2.0框架Web应用程序。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆