I am developing an application that generates marketing emails, creates them as campaigns in Constant Contact, then sends them to a selected list (well, that's the plan...) I've got the campaigns going in absolutely fine. They appear straight away in the campaign list as a DRAFT, with the correct list attached. But when I try using the addSchedule method of the campaignScheduleService, it doesn't seem to work. No errors are coming back, but the campaigns are not sent. Here's what I have... $cc = new ConstantContact(API_KEY);
$campaign = new Campaign();
$campaign->name = $campaignName;
$campaign->subject = $subject;
$campaign->from_name = 'Eric Young & Co';
$campaign->from_email = $from;
$campaign->reply_to_email = $from;
$campaign->text_content = strip_tags($markup);
$campaign->email_content = $markup;
// Add the chosen list to the campaign
$campaign->addList($_POST['list']);
try {
$c = $cc->emailMarketingService->addCampaign(ACCESS_TOKEN, $campaign);
} catch (CtctException $ex) {
print('<pre>'.print_r($ex->getErrors(), true).'</pre>');
}
// WORKS FINE UP UNTIL HERE
// Do we want to send this campaign as well?
if($_POST['send'] == 'true') {
print("TRYING SCHEDULE: " . ACCESS_TOKEN . ", " . $c->id . ", " . date('Y-m-d\TH:i:s\.000\Z', strtotime('+30 seconds')));
// THIS PRINTS OUT ALL THREE PARAMETERS CORRECTLY
$schedule = new Schedule();
$schedule->scheduled_date = date('Y-m-d\TH:i:s\.000\Z', strtotime('+30 seconds'));
try {
$result = $cc->campaignScheduleService->addSchedule(ACCESS_TOKEN, $c->id, $schedule);
print('<pre>'.print_r($result, true).'</pre>');
} catch (CtctException $ex) {
print('<pre>'.print_r($ex->getErrors(), true).'</pre>');
}
} Nothing is returned from $result, not any errors generated. Any ideas? Thanks.
... View more