1
0
Fork 0
song-caller/caller.php
Andrew Tomaka 4a3749883b Add Multicall Support
Implement multicall support by using an sqlite database to store and
retrieve calls.  Two interfaces have been added:

1) add-call.php.  Used to add calls.
example: add-call.php 15555555555 '0 10-16 * * *' 'http://www.domain.com/xml.xml'

2) create-table.php.  Creates the database file

Created calls are retrieved in the caller.php file.  Each call is run
through the scheduler to verify if it is time for it to be made.
2013-03-04 19:27:42 -05:00

36 lines
834 B
PHP

<?php
require 'vendor/autoload.php';
require 'vendor/twilio/sdk/Services/Twilio.php';
use Symfony\Component\Yaml\Yaml;
$crontab = new \HybridLogic\Cron\Crontab;
$db = new PDO('sqlite:db/songcaller.db');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$settings = Yaml::parse('conf/settings.yml');
$client = new Services_Twilio(
$settings['twilio']['sid'],
$settings['twilio']['token']
);
$result = $db->query('SELECT * FROM calls');
foreach($result as $row) {
$crontab->add_job(
\HybridLogic\Cron\Job::factory('test')
->on($row['schedule'])
->trigger(function() use($settings, $client, $row) {
$call = $client->account->calls->create(
$settings['application']['from'],
$row['phone'],
$row['xml']
);
})
);
}
$crontab->run();
$db = null;