1
0
Fork 0
song-caller/caller.php
Andrew Tomaka b7fb4c8ced Automatically Generate XML Files
Implement xml-generator.php that will automatically generate XML files
from the database based on an ID passed in a get query.  This allows
new calls to be added using new MP3s without having to create a new XML
file by hand everytime.  This is the first step to a full web
implementation.
2013-03-05 11:37:28 -05:00

36 lines
900 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 id, schedule, phone 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'],
$settings['application']['generator'] . '?id=' . $row['id']
);
})
);
}
$crontab->run();
$db = null;