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.

Script Fails Using PHP SDK

Established Member

Script Fails Using PHP SDK

I am upgrading a script from v1 to v2 of API.  Using the PHP SDK.  I require autoload.php then added the use statements.  I am trying to create and schedule an email.  I based this on the  example file "createAndScheduleCampaign.php"


Script fails without producing any error or output.  I have narrowed it down to the use statements.  Using PHP 5.3.3

Established Member

Re: Script Fails Using PHP SDK

Found an error php


call to private Campaign::__construct() from invalid context


Here is code snipit;


include '/var/www/httpdocs/Ctct/autoload.php';
use Ctct\ConstantContact;
use Ctct\Components\Contacts\ContactList;
use Ctct\Components\EmailMarketing\Campaign;
use Ctct\Components\EmailMarketing\MessageFooter;
use Ctct\Components\EmailMarketing\Schedule;
use Ctct\Exceptions\CtctException;


$cc = new ConstantContact(APIKEY);

function createCampaign() {
         global $CName;
         global $emailSubject;
         global $emailFormName;
         global $emailFormEmail;
         global $emailText;
         global $ConstantContactMailBodyFinal;
         global $list;

         $cc = new ConstantContact(APIKEY);
         $campaign1 = new Campaign();   ERROR HERE



Regular Advisor

Re: Script Fails Using PHP SDK



What you have posted looks fine.  Would you mind sending me a PM with the source?  Thanks.


Andrew B.

Constant Contact

API Support

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