We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

Script Fails Using PHP SDK


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


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





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