0

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

4

1 回答 1

1

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.

于 2012-04-10T10:30:46.737 回答