The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

Issue getting a campaign to send with campaignScheduleService (PHP SDK)

Highlighted
Visitor

Issue getting a campaign to send with campaignScheduleService (PHP SDK)

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.

1 REPLY 1
Highlighted
Moderator

Re: Issue getting a campaign to send with campaignScheduleService (PHP SDK)

Hello,

Thank you for reaching out to Constant Contact API Support.

So you are not getting any response back from the API at all, correct? I wonder if this is a PHP error. I would check to see that errors and warnings are turned on in your php config and try again. This could clue us in on what the problem might be.

Also, if you send us an email (webservices@constantcontact.com) with your API Key and the username of the Constant Contact account you are working in, we can do some digging into our logs here as well.

Sincerely,
David B.
Tier II API Support Engineer

Developer Portal

View API documentation, code samples, get your API key.

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured