* @param $campaignId - Id of the campaign to be scheduled
 * @param $time - ISO 8601 formatted timestamp of when the campaign should be sent
 * @return Schedule updated by server
 */
function createSchedule($campaignId, $time)
{
    $cc = new ConstantContact(APIKEY);
    $schedule = new Schedule();
    $schedule->scheduled_date = $time;
    return $cc->campaignScheduleService->addSchedule(ACCESS_TOKEN, $campaignId, $schedule);
}
// check to see if the form was submitted
if (isset($_POST['name'])) {
    // attempt to create a campaign with the fields submitted, displaying any errors that occur
    try {
        $campaign = createCampaign($_POST);
    } catch (CtctException $ex) {
        echo '<span class="label label-important">Error Creating Campaign</span>';
        echo '<div class="container alert-error"><pre class="failure-pre">';
        print_r($ex->getErrors());
        echo '</pre></div>';
        die;
    }
    // attempt to schedule a campaign with the fields submitted, displaying any errors that occur
    try {
        $schedule = createSchedule($campaign->id, $_POST['schedule_time']);
    } catch (CtctException $ex) {
        echo '<span class="label label-important">Error Scheduling Campaign</span>';
        echo '<div class="container alert-error"><pre class="failure-pre">';
        print_r($ex->getErrors());
        echo '</pre></div>';
Esempio n. 2
0
<?php

include 'includes/header.php';
require_once DIR_APP . 'projects.php';
require_once DIR_APP . 'users.php';
if (empty($_SESSION['logged_in'])) {
    redirect('index.php');
}
if (isset($_GET['mode']) && $_GET['mode'] == 'manage') {
    $mode = 'manage';
} else {
    $mode = 'create';
}
$user = getUserData($_SESSION['uid']);
if (isset($_POST['finalize'])) {
    $res = createCampaign($_POST);
    if ($res) {
        redirect('advertisement.php?mode=manage');
    }
}
if (isset($_POST['finalize_edit'])) {
    $res = editCampaign($_POST, intval($_GET['cid']));
    if ($res) {
        redirect('advertisement.php?mode=manage');
    }
}
if (isset($_GET['action']) && $_GET['action'] == 'delete') {
    deleteAd(intval($_GET['cid']));
    redirect('advertisement.php?mode=manage');
}
if (isset($_GET['action']) && $_GET['action'] == 'pause') {
Esempio n. 3
0
        $_SESSION['campaign_address'] = $_POST['address'];
        $_SESSION['campaign_latlng'] = $_POST['latlng'];
        nextStage();
    }
}
if ($stage == 3) {
    if (isset($_POST['logo']) and isset($_POST['excerpt']) and isset($_POST['description'])) {
        $_SESSION['campaign_logo'] = $_POST['logo'];
        $_SESSION['campaign_excerpt'] = $_POST['excerpt'];
        $_SESSION['campaign_description'] = $_POST['description'];
        nextStage();
    }
}
if ($stage >= 4) {
    if (isset($_POST['submit'])) {
        createCampaign();
    }
}
/**
 * Iterates the campaign stage
 */
function nextStage()
{
    global $stage;
    if ($stage < 1) {
        $stage = 1;
    }
    if ($stage > 4) {
        $stage = 4;
    }
    $stage++;
Esempio n. 4
0
    curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
    $result = curl_exec($curl);
    $result = json_decode($result, true);
    $result_info = curl_getinfo($curl);
    $result_status = $result_info['http_code'];
    $campaign_id = $result['id'];
    $out = ">\tcampaign: {$campaign_id}\n>\ttitle: {$result['title']}\n>\treport: http://{$dc}.admin.mailchimp.com/reports/summary?id={$result['web_id']}\n>\tsend: https://{$dc}.admin.mailchimp.com/campaigns/wizard/confirm?id={$result['web_id']}\n\n";
    echo $out;
    return $campaign_id;
}
//-----------------------------------------------------------------
$emails = getList($list_id);
if ($emails) {
    if ($create_campaign) {
        $campaign_id = createCampaign();
    }
    $order_id = generateOrderId();
    $inc = 0;
    foreach ($emails as $email_address => $email_id) {
        $orders[] = new Order($email_address, $email_id, $campaign_id, $store_id, $store_name, $products, $order_id + $inc);
        $inc++;
    }
    addOrders($orders);
    if ($inc > 50) {
        echo $out;
    }
}
$end_time = date('H:i:s', time());
$elapsed_time = abs(strtotime($end_time) - strtotime($start_time));
echo "{$elapsed_time}s elapsed\n\n";
/**
 * function that creates a campaign and adds to the
 * account.
 */
function addCampaign($campaignService, $accountID)
{
    global $SAMPLE_DATA;
    $now = time();
    $campaign = createCampaign(NULL, $SAMPLE_DATA['CAMPAIGN_NAME'], $SAMPLE_DATA['CAMPAIGN_DESCRIPTION'], $accountID, 'On', true, true, false, true, date("c", $now + 60 * 60 * 24), date("c", $now + 60 * 60 * 24 * 365));
    debug("Calling addCampaign");
    $retObj = execute($campaignService, 'addCampaign', array('campaign' => $campaign));
    checkResponse($retObj);
    debug("------> Campaign ID: " . $retObj->out->campaign->ID);
    return $retObj->out->campaign;
}