Skip to content

Instantly share code, notes, and snippets.

@ksnider
Last active December 31, 2015 19:39
Show Gist options
  • Select an option

  • Save ksnider/8035217 to your computer and use it in GitHub Desktop.

Select an option

Save ksnider/8035217 to your computer and use it in GitHub Desktop.
<?php
// Connect to Infusionsoft
require_once("isdk.php");
$app = new iSDK;
if ($app->cfgCon("connectionName")) {
// Connect to database
$con = mysql_connect("localhost","ksnider_kim","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$db = mysql_select_db("ksnider_reminders", $con);
if (!$db)
{
die('Could not find table: ' . mysql_error());
}
echo $current_time = date("Y-m-d H:i:s") ."<br/><br/>";
/*
Query db looking for 'send' less than Now() AND 'sent' null, meaning
we are within the window when we want to send the text and we
haven't sent it yet.
*/
$query = "
SELECT * FROM `ksnider_reminders`.`webinar_1hr_email`
WHERE `send` <= NOW( )
AND `sent` IS NULL;
";
$reminders = mysql_query($query);
while($row = mysql_fetch_array($reminders, MYSQL_ASSOC))
{
$contactId = $row['contactId'];
echo 'Email:'.$contactId.'<br/>';
// Send email using template
echo $app->sendTemplate(array($contactId), 4143);
// Update text sent field with current timestamp so we know a text has been sent and
// won't resend next time the cron runs
$query = "
UPDATE `webinar_1hr_email` SET `sent`= Now() WHERE `contactId` = $contactId;
";
mysql_query($query);
}
mysql_close($con);
} else {
echo "Not Connected...";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment