<?php 
    if (isset($_POST['campaign_name'])) {
        $Campaign = new Campaign();
        $Campaign->name = $_POST['campaign_name'];
        $Campaign->subject = $_POST['subject_line'];
        $Campaign->fromName = $_POST['from_name'];
        $Campaign->vawp = $_POST['webpage_version'];
        $Campaign->vawpText = $_POST['webpage_version_text'];
        $Campaign->vawpLinkText = $_POST['webpage_link_text'];
        $Campaign->permissionReminder = $_POST['permission_reminder'];
        $Campaign->permissionReminderText = $_POST['permission_reminder_text'];
        $Campaign->inchorwardEmail = $_POST['forward_link'];
        $Campaign->forwardEmailLinkText = $_POST['forward_link_text'];
        $Campaign->incSubscribeLink = $_POST['subscribe_link'];
        $Campaign->subscribeLinkText = $_POST['subscribe_link_text'];
        $Campaign->emailContentType = $_POST['email_type'];
        $Campaign->emailContent = $_POST['email_content'];
        $Campaign->textVersionContent = $_POST['text_version'];
        $Campaign->styleSheet = $_POST['style_sheet'];
        $Campaign->lists = $_POST['lists'];
        // add campaign to Constant Contact account
        $NewCampaign = $ConstantContact->addCampaign($Campaign, $VerifiedAddresses['addresses'][$_POST['from']], $VerifiedAddresses['addresses'][$_POST['reply_to']]);
        if ($NewCampaign) {
            echo "Campaign Added. This is your newly created campaign's raw information<br /><pre>";
            print_r($NewCampaign);
            echo "</pre>";
        }
    }
} else {
    echo ' Click <a href="../example_verification.php?apiKey=' . $apiKey . '&secret=' . $consumerSecret . '&return=' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '">here</a> to authorize';
}
             $myCampaign->link = str_replace("http://api.constantcontact.com", "", $myCampaign->id);
             // Stores results of our PUT, if false malformed XML was passed
             // in or to incorrect URI
             $TestingUpdate = $ConstantContact->updateCampaign($myCampaign);
             if ($TestingUpdate != false) {
                 // Put was a success
                 $CampaignResult = $ConstantContact->getCampaignByID($_GET["campaignID"]);
             } else {
                 // Stores all the information from the get back to the form
                 // fields so you can modify your data
                 $CampaignResult = $ConstantContact->getCampaignByID($_GET["campaignID"]);
                 $UpdateError = TRUE;
             }
         } else {
             // Adds your new campaign to your Constant Contact Account
             $CampaignResult = $ConstantContact->addCampaign($myCampaign, $fromAddress);
             // $CampaignResult will now hold the referenced campaign object
             $lastCampaigns = $ConstantContact->getCampaigns();
             if (isset($CampaignResult->status)) {
                 foreach ($lastCampaigns['campaigns'] as $recent) {
                     if ($recent->name == $CampaignResult->name) {
                         $CampaignResult == $ConstantContact->getCampaignDetails($recent);
                     }
                 }
             }
         }
         // Catch all errors
     } catch (Exception $e) {
         echo $e . " needs to be corrected before submission";
     }
 }