Dre4m Shell
Server IP : 127.0.0.2  /  Your IP : 3.129.209.49
Web Server : Apache/2.4.18 (Ubuntu)
System :
User : www-data ( )
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/vendor/constantcontact/constantcontact/examples/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /var/www/html/vendor/constantcontact/constantcontact/examples/createAndScheduleCampaign.php
<!DOCTYPE HTML>
<html>
<head>
    <title>Constant Contact API v2 Create/Schedule Campaign Example</title>
    <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
    <link href="styles.css" rel="stylesheet">
</head>

<!--
README: Create and schedule an email marketing campaign for delivery
This example flow illustrates how to create a new email campaign, and schedule it to be sent to the selected contact lists(s). 
In order for this example to function properly, you must have a valid Constant Contact API Key as well as an access token. Both of these 
can be obtained from http://constantcontact.mashery.com.

NOTE: This example expects that your account already has a physical address set up in your Constant Contact account settings.
For more information on this, please visit: http://support2.constantcontact.com/articles/FAQ/2801#future%20emails
-->

<?php
// require the autoloaders
require_once '../src/Ctct/autoload.php';
require_once '../vendor/autoload.php';

use Ctct\ConstantContact;
use Ctct\Components\EmailMarketing\Campaign;
use Ctct\Components\EmailMarketing\Schedule;
use Ctct\Exceptions\CtctException;

// Enter your Constant Contact APIKEY and ACCESS_TOKEN
define("APIKEY", "ENTER YOUR API KEY");
define("ACCESS_TOKEN", "ENTER YOUR ACCESS TOKEN");

$cc = new ConstantContact(APIKEY);
$date = date('Y-m-d\TH:i:s\.000\Z', strtotime("+1 month"));

/**
 * Create an email campaign with the parameters provided
 * @param array $params associative array of parameters to create a campaign from
 * @return Campaign updated by server
 */
function createCampaign(array $params = array())
{
    $cc = new ConstantContact(APIKEY);
    $campaign = new Campaign();
    $campaign->name = $params['name'];
    $campaign->subject = $params['subject'];
    $campaign->from_name = $params['from_name'];
    $campaign->from_email = $params['from_addr'];
    $campaign->greeting_string = $params['greeting_string'];
    $campaign->reply_to_email = $params['reply_to_addr'];
    $campaign->text_content = $params['text_content'];
    $campaign->email_content = $params['email_content'];
    $campaign->email_content_format = $params['format'];

    // add the selected list or lists to the campaign
    if (isset($params['lists'])) {
        if (count($params['lists']) > 1) {
            foreach ($params['lists'] as $list) {
                $campaign->addList($list);
            }
        } else {
            $campaign->addList($params['lists'][0]);
        }
    }

    return $cc->emailMarketingService->addCampaign(ACCESS_TOKEN, $campaign);
}

/**
 * Create a schedule for a campaign - this is time the campaign will be sent out
 * @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>';
        die();
    }

}

// attempt to get the lists in this account, displaying any errors that occur
try {
    $lists = $cc->listService->getLists(ACCESS_TOKEN);
} catch (CtctException $ex) {
    echo '<div class="container alert-error"><pre class="failure-pre">';
    print_r($ex->getErrors());
    echo '</pre></div>';
    die();
}
?>

<body>
<div class="well">
    <h3>Create and Schedule a Campaign</h3>

    <form class="form-horizontal" name="emailForm" id="emailForm" method="POST" action="createAndScheduleCampaign.php">
        <div class="span6">
            <fieldset>
                <div class="control-group">
                    <label class="control-label" for="name">Campaign Name</label>

                    <div class="controls">
                        <input type="text" id="name" name="name" class="required" placeholder="Campaign Name">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="subject">Subject</label>

                    <div class="controls">
                        <input type="text" id="subject" name="subject" placeholder="Subject">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="from_name">From Name</label>

                    <div class="controls">
                        <input type="text" id="from_name" name="from_name" placeholder="From Name">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="from_addr">From Email</label>

                    <div class="controls">
                        <input type="email" id="from_addr" name="from_addr" placeholder="From Email">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="name">Text Content</label>

                    <div class="controls">
                        <textarea id="text_content" name="text_content" placeholder="Text Content"></textarea>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="email_content">Email Content</label>

                    <div class="controls">
                        <textarea id="email_content" name="email_content" placeholder="Email Content"></textarea>
                    </div>
                </div>
            </fieldset>
        </div>

        <div class="span6">
            <fieldset>
                <div class="control-group">
                    <label class="control-label" for="greeting_string">Greeting String</label>

                    <div class="controls">
                        <input type="text" id="greeting_string" name="greeting_string" placeholder="Greeting String">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="reply_to_addr">Reply-To Email</label>

                    <div class="controls">
                        <input type="email" id="reply_to_addr" name="reply_to_addr" placeholder="Reply To">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="format">Lists to send to: </label>

                    <div class="controls">
                        <select multiple="multiple" name="lists[]" size="8">
                            <?php
                            foreach ($lists as $list) {
                                echo '<option value="' . $list->id . '" >' . $list->name . '</option><br />';
                            }
                            ?>
                        </select>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="format">Send Time</label>

                    <div class="controls">
                        <input type="text" name="schedule_time" id="schedule_time"
                               value="<?php echo date('Y-m-d\TH:i:s\.000\Z', strtotime("+1 month"));
                               ; ?>"/>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="format">Email Content Format</label>

                    <div class="controls">
                        <input type="radio" id="name" name="format" value="HTML" checked> HTML
                        <input type="radio" id="name" name="format" value="XHTML"> XHTML
                    </div>
                </div>
            </fieldset>
        </div>
        <br clear="all"/>

        <div class="control-group">
            <label class="control-label">
                <div class="controls">
                    <input type="submit" value="Create & Schedule" class="btn btn-primary"/>
                </div>
        </div>

    </form>
</div>

<?php

// print the contents of the campaign to screen
if (isset($campaign)) {
    echo '<span class="label label-success">Campaign Created!</span>';
    echo '<div class="container alert-success"><pre class="success-pre">';
    print_r($campaign);
    echo '</pre></div>';
}

// print the contents of the schedule to screen
if (isset($schedule)) {
    echo '<span class="label label-success">Campaign Scheduled!</span>';
    echo '<div class="container alert-success"><pre class="success-pre">';
    print_r($schedule);
    echo '</pre></div>';
}
?>

</body>
</html>

Anon7 - 2022
AnonSec Team