This repository has been archived by the owner on Dec 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Campaigns
focorunner edited this page Aug 7, 2012
·
9 revisions
###Get list of Campaigns
<?php
// Get first page of campaigns
$campaigns = $ConstantContact->getCampaigns();
// Get second page of campaigns
$moreCampaigns = $ConstantContact->getCampaigns($campaigns['nextlink']);
?>
###Get Campaign Details
<?php
// Get first page of campaigns
$campaigns = $ConstantContact->getCampaigns();
// Get details of the first campaign returned
$details = $ConstantContact->getCampaignDetails($campaigns['campaigns'][0]);
?>
###Get Campaigns by Status
<?php
$campaigns = $ConstantContact->getCampaignsByStatus('sent');
?>
###Create a Campaign
<?php
// Get verified account addresses
$VerifiedAddresses = $ConstantContact->getVerifiedAddresses();
// Create new campaign object
$Campaign = new Campaign();
// Set unique campaign variables in object
$Campaign->name = "New Campaign";
$Campaign->subject = "Subject Line here";
$Campaign->emailContent = "<html><body>Hello!</body></html>";
$Campaign->textVersionContent = "This is my text version";
// Create campaign in Constant Contact Account, first verified address as from and reply-to
$ConstantContact->addCampaign($Campaign, $VerifiedAddresses['addresses'][0])
?>
###Update a Campaign
<?php
// Get the first page of campaigns
$campaigns = $ConstantContact->getCampaigns();
// Get the details of the first campaign returned
$myCampaign = $ConstantContact->getCampaignDetails($campaigns['campaigns'][0]);
// Assign new properties
$myCampaign->subject = "My new subject line";
// Update the campaign
$update = $ConstantContact->updateCampaign($myCampaign);
?>
<?php
// Get the first page of campaigns
$campaigns = $ConstantContact->getCampaigns();
// Delete the first campaign returned
$delete = $ConstantContact->deleteCampaign($myCampaign);
?>
###Get Campaign Reporting Data
<?php
// Get sent campaigns
$campaigns = $ConstantContact->getCampaignsByStatus('sent');
// Set $myCampaign to the first returned campaign
$myCampaign = $campaigns['campaigns'][0];
// Get various reporting data for the campaign
$sends = $ConstantContact->getCampaignSends($myCampaign);
$opens = $ConstantContact->getCampaignOpens($myCampaign);
$optouts = $ConstantContact->getCampaignOptOuts($myCampaign);
$bounces = $ConstantContact->getCampaignBounces($myCampaign);
$forwards = $ConstantContact->getCampaignForwards($myCampaign);
?>
###Schedule a Campaign to be sent
<?php
// Get draft campaigns
$campaigns = $ConstantContact->getCampaignsByStatus('draft');
// Schedule the campaign for delivery
$schedule = $ConstantContact->scheduleCampaign($campaigns['campaigns'][0], '2011-11-13T20:03:35.000Z');
?>
###Get a Campaign's schedule
<?php
// Get a list of scheduled campaigns
$campaigns = $ConstantContact->getCampaignsByStatus('scheduled');
// Get the schedule for the first returned campaign
$Schedule = $ConstantContact->getCampaignSchedule($campaigns['campaigns'][0]);
?>
###Cancel a scheduled Campaign from sending
<?php
// Get a list of scheduled campaigns
$campaigns = $ConstantContact->getCampaignsByStatus('scheduled');
// Delete the schedule of the first returned Campaign
$deleteSchedule = $ConstantContact->deleteCampaignSchedule($camps['campaigns'][0]);
?>