1
0
Fork 0
song-caller/caller.php
Andrew Tomaka fcf0ef7c58 Add Scheduling Capabilities
Implement a scheduler based on crontab to execute calls at specific
times.  Using PHP-Cron, we can implement a single cron at the system
level and then use methods to add cron jobs at the PHP level.  This
allows eventually expansion to handling multiple song calls.
2013-02-26 17:27:12 -05:00

28 lines
651 B
PHP

<?php
require 'vendor/autoload.php';
require 'vendor/twilio/sdk/Services/Twilio.php';
use Symfony\Component\Yaml\Yaml;
$crontab = new \HybridLogic\Cron\Crontab;
$settings = Yaml::parse('conf/settings.yaml');
$client = new Services_Twilio(
$settings['twilio']['sid'],
$settings['twilio']['token']
);
$crontab->add_job(
\HybridLogic\Cron\Job::factory('test')
->on('0 10-16 * * *')
->trigger(function() use($settings, $client) {
$call = $client->account->calls->create(
$settings['application']['from'],
$settings['application']['to'],
$settings['application']['xml']
);
})
);
$crontab->run();