本文整理汇总了PHP中MCAPI::campaigns方法的典型用法代码示例。如果您正苦于以下问题:PHP MCAPI::campaigns方法的具体用法?PHP MCAPI::campaigns怎么用?PHP MCAPI::campaigns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MCAPI
的用法示例。
在下文中一共展示了MCAPI::campaigns方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: MCAPI
<?php
/**
This Example shows how to retrieve a list of your campaigns via the MCAPI class.
**/
require_once '../mcapi.php';
require_once 'config/config.inc.php';
//contains apikey
$api = new MCAPI($apikey);
$retval = $api->campaigns();
if ($api->errorCode) {
echo "Unable to Pull list of Campaign!";
echo "\n\tCode=" . $api->errorCode;
echo "\n\tMsg=" . $api->errorMessage . "\n";
} else {
echo sizeof($retval['total']) . " Total Campaigns Matched.\n";
echo sizeof($retval['data']) . " Total Campaigns returned:\n";
foreach ($retval['data'] as $c) {
echo "Campaign Id: " . $c['id'] . " - " . $c['title'] . "\n";
echo "\tStatus: " . $c['status'] . " - type = " . $c['type'] . "\n";
echo "\tsent: " . $c['send_time'] . " to " . $c['emails_sent'] . " members\n";
}
}
示例2: campaigns
function campaigns()
{
$campaigns = parent::campaigns();
if (!$this->lists) {
$this->lists();
}
foreach ($campaigns['data'] as &$campaign) {
$campaign['listname'] = ($name = $this->ids_lists[$campaign['list_id']]['name']) ? $name : "No";
}
return $campaigns;
}
示例3: a360_request_handler
function a360_request_handler()
{
if (!empty($_GET['a360_action'])) {
switch ($_GET['a360_action']) {
case 'admin_js':
a360_admin_js();
break;
case 'admin_css_ie':
header('Content-type: text/css');
require 'css/a360-ie.css';
die;
break;
case 'admin_css':
header('Content-type: text/css');
require 'css/datePicker.css';
require 'css/a360.css';
die;
break;
case 'capture_ga_token':
if (!current_user_can('manage_options')) {
wp_die(__('You are not allowed to do that.', 'analytics360'));
}
$args = array();
parse_str($_SERVER['QUERY_STRING'], $args);
$token = NULL;
if (isset($args['token'])) {
$ch = curl_init('https://www.google.com/accounts/AuthSubSessionToken');
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: AuthSub token="' . $args['token'] . '"'));
$result = curl_exec($ch);
$matches = array();
$found = preg_match('/Token=(.*)/', $result, $matches);
if ($found) {
$token = $matches[1];
$result = update_option('a360_ga_token', $token);
}
}
if (!$token) {
$q = http_build_query(array('a360_error' => 'Authentication with Google did not succeed. Please try again.'));
} else {
delete_option('a360_ga_profile_id');
$q = http_build_query(array('updated' => true));
}
wp_redirect(trailingslashit(get_bloginfo('wpurl')) . 'wp-admin/options-general.php?page=' . basename(__FILE__) . '&' . $q);
break;
case 'get_wp_posts':
add_filter('posts_where', create_function('$where', 'return $where." AND post_date >= \'' . $_GET['start_date'] . '\' AND post_date < \'' . $_GET['end_date'] . '\'";'));
$results = query_posts('post_status=publish&posts_per_page=999');
header('Content-type: text/javascript');
die(cf_json_encode(array('success' => true, 'data' => $results, 'cached' => false)));
break;
case 'get_mc_data':
global $a360_api_key;
if (!class_exists('MCAPI')) {
include_once ABSPATH . PLUGINDIR . '/analytics360/php/MCAPI.class.php';
}
$api = new MCAPI($a360_api_key);
switch ($_GET['data_type']) {
case 'campaigns':
$results = $api->campaigns(array('sendtime_start' => $_GET['start_date'], 'end_start' => $_GET['end_date']));
if ($results) {
die(cf_json_encode(array('success' => true, 'data' => $results, 'cached' => false)));
} else {
die(cf_json_encode(array('success' => false, 'error' => $api->errorMessage)));
}
break;
case 'list_growth':
$results = $api->listGrowthHistory($_GET['list_id']);
if ($results) {
die(cf_json_encode(array('success' => true, 'data' => $results, 'cached' => false)));
} else {
die(cf_json_encode(array('success' => false, 'error' => $api->errorMessage)));
}
break;
}
break;
case 'get_ga_data':
global $a360_ga_token, $a360_ga_profile_id;
$parameters = array('start-date' => $_GET['start_date'], 'end-date' => $_GET['end_date'], 'sort' => 'ga:date', 'ids' => 'ga:' . $a360_ga_profile_id);
// split up top referrals by filtering on each medium in turn
if ($_GET['data_type'] == 'top_referrals') {
$handles = array('referral' => null, 'organic' => null, 'email' => null, 'cpc' => null, '*' => null);
$parameters['dimensions'] = 'ga:medium,ga:source';
$parameters['metrics'] = 'ga:visits,ga:timeOnSite,ga:pageviews';
$parameters['sort'] = '-ga:visits';
foreach ($handles as $filter => $handle) {
$p = $filter == '*' ? array('max-results' => 200) : array('filters' => 'ga:medium==' . $filter, 'max-results' => 200);
$handles[$filter] = $handle = curl_init('https://www.google.com/analytics/feeds/data?' . http_build_query(array_merge($parameters, $p)));
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_TIMEOUT, 10);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, true);
curl_setopt($handle, CURLOPT_HTTPHEADER, array('Authorization: AuthSub token="' . $a360_ga_token . '"'));
}
$mh = curl_multi_init();
foreach ($handles as $handle) {
curl_multi_add_handle($mh, $handle);
//.........这里部分代码省略.........
示例4: MCAPI
function campaign_archive()
{
$api_key = $this->EE->TMPL->fetch_param('api_key');
$list_id = $this->EE->TMPL->fetch_param('list_id');
$folder_id = $this->EE->TMPL->fetch_param('folder_id');
$status = $this->EE->TMPL->fetch_param('status');
$limit = $this->EE->TMPL->fetch_param('limit');
if (!$api_key) {
return;
}
$api = new MCAPI($api_key);
$filters = "";
// Apply by list filter
if ($list_id) {
$filters['list_id'] = $list_id;
}
// Apply by folder filter
if ($folder_id) {
$filters['folder_id'] = $folder_id;
}
// Apply by status filter
if ($status) {
$filters['status'] = $status;
}
$result = $api->campaigns($filters);
if ($api->errorCode) {
$this->EE->TMPL->log_item('Mailchimp EE: Campaign Archive failed, Mailchimp API complained - ' . $api->errorMessage . ' (' . $api->errorCode . ')');
}
// Make sure there is at least one campaign
if (count($result) == 0) {
return;
}
// Apply limit
if ($limit) {
$result = array_slice($result, 0, $limit);
}
$vars = $result;
// Convert date values into timestamps
foreach ($vars as $key => $value) {
$vars[$key]['send_time'] = strtotime($value['send_time']);
$vars[$key]['create_time'] = strtotime($value['create_time']);
}
return $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $vars);
}