Can SMS be saved and scheduled for delivery in Twilio? If not, how do I get this done?

让人想犯罪 __ 提交于 2019-12-11 01:54:59

问题


I just signed up for a Twilio trial account. I'm not seeing any feature speaking to how I can create and save multiple SMS messages for later and schedule when to send them to a group. Is this possible? Or is there a better software for this?


回答1:


Twilio evangelist here.

Looking at your profile, seems your preferred language is PHP, so what I would suggest is using one of the many PHP libraries for cron tasks such as PHPCron, PHPJobScheduler or with the Piwik Platform.

With Piwik you could do something like:

class Tasks extends \Piwik\Plugin\Tasks
{
    public function schedule()
    {
        $this->daily('myTask');   // method will be executed once every day
    }

    public function myTask()
    {
        You SMS messages to be sent here
    }
}

With this, you can schedule as many tasks as you'd like, and have the SMS's sent at the time you want them to be sent.

There are going to be task schedulers to pretty much every single platform, and you could even do those via cron tasks.




回答2:


I'm a little late to this question, but I'd like to suggest to anyone that arrives here now: check out the at command. From PHP, your server can execute command line calls to at and schedule tasks with absolute or relative temporal specificity.

Relative MWE:

shell_exec('echo "php /path/to/my/twilio_script.php" | at now + 10 minutes');

Absolute MWE:

shell_exec('echo "php /path/to/my/twilio_script.php" | at 3:35 PM 10/29/2019');

You have to mind permissions (check your etc/at.deny and that your server has permissions to execute your script), and the quotations if your script has any command line arguments. But it avoids the creation of a bunch of Cron jobs.

You could also create files to execute (scroll down a couple of answers) with at - these could be individual messages to send using twilio. It's not my favorite approach, but I suppose there are situations that it would be better-suited over the other approach. But I'd recommend a Cron cleanup script to remove all of the one-time use files.



来源:https://stackoverflow.com/questions/28436927/can-sms-be-saved-and-scheduled-for-delivery-in-twilio-if-not-how-do-i-get-this

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!