├── campaign_monitor ├── config │ ├── campaign_monitor_routes.php │ ├── campaign_monitor_constants.php │ └── campaign_monitor.php ├── assets │ ├── images │ │ └── ico_campaign_monitor.png │ └── css │ │ └── campaign_monitor.css ├── language │ └── english │ │ └── campaign_monitor_lang.php ├── views │ └── campaign_monitor.php ├── controllers │ └── dashboard.php └── libraries │ └── CMBase.php ├── clicky ├── assets │ ├── images │ │ └── xtra_clicky.png │ ├── css │ │ └── clicky.css │ └── cache │ │ └── clicky.css ├── config │ ├── clicky_routes.php │ ├── index.html │ ├── clicky_constants.php │ └── clicky.php ├── views │ ├── index.html │ └── clicky_dashboard.php ├── libraries │ └── index.html └── controllers │ ├── index.html │ └── dashboard.php ├── wordpress ├── assets │ ├── images │ │ └── xtra_wordpress.png │ └── css │ │ └── wordpress.css ├── config │ ├── wordpress_routes.php │ ├── index.html │ ├── wordpress_constants.php │ └── wordpress.php ├── views │ ├── index.html │ └── wordpress_dashboard.php ├── controllers │ ├── index.html │ └── dashboard.php └── helpers │ └── wordpress_helper.php ├── phpmyadmin ├── assets │ ├── images │ │ └── xtra_phpmyadmin.png │ └── css │ │ └── phpmyadmin.css ├── config │ ├── index.html │ ├── phpmyadmin_routes.php │ ├── phpmyadmin_constants.php │ └── phpmyadmin.php ├── views │ ├── index.html │ └── phpmyadmin_dashboard.php └── controllers │ ├── index.html │ └── dashboard.php ├── google_analytics ├── assets │ ├── images │ │ └── xtra_google_analytics.png │ └── css │ │ └── google_analytics.css ├── views │ ├── index.html │ └── google_analytics_dashboard.php ├── config │ ├── index.html │ ├── google_analytics_routes.php │ ├── google_analytics_constants.php │ └── google_analytics.php └── controllers │ ├── index.html │ └── dashboard.php └── README /campaign_monitor/config/campaign_monitor_routes.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /wordpress/config/wordpress_routes.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /clicky/libraries/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /google_analytics/assets/images/xtra_google_analytics.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daylightstudio/FUEL-CMS-Modules-Pack/HEAD/google_analytics/assets/images/xtra_google_analytics.png -------------------------------------------------------------------------------- /phpmyadmin/config/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /phpmyadmin/config/phpmyadmin_routes.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /wordpress/config/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /wordpress/views/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /campaign_monitor/assets/css/campaign_monitor.css: -------------------------------------------------------------------------------- 1 | .ico_tools_campaign_monitor { background-image: url(../images/ico_campaign_monitor.png); } 2 | .campaign { float: left; padding-right: 30px; } -------------------------------------------------------------------------------- /clicky/config/clicky_constants.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /google_analytics/views/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /phpmyadmin/controllers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /wordpress/controllers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /google_analytics/config/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /google_analytics/controllers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /wordpress/assets/css/wordpress.css: -------------------------------------------------------------------------------- 1 | div#dashboard_wordpress a { display: block; width: 180px; text-align: right; background: transparent url(../images/xtra_wordpress.png) no-repeat 5px center; padding: 6px; } -------------------------------------------------------------------------------- /wordpress/config/wordpress_constants.php: -------------------------------------------------------------------------------- 1 | load->config('wordpress'); 10 | $config = $this->config->item('wordpress'); 11 | $this->_validate_user($config['permission']); 12 | $this->load->vars($config); 13 | } 14 | 15 | function index() 16 | { 17 | $this->load->view('wordpress_dashboard'); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /phpmyadmin/controllers/dashboard.php: -------------------------------------------------------------------------------- 1 | load->config('phpmyadmin'); 10 | $config = $this->config->item('phpmyadmin'); 11 | $this->_validate_user($config['permission'], NULL, FALSE); 12 | $this->load->vars($config); 13 | } 14 | 15 | function index() 16 | { 17 | $this->load->view('phpmyadmin_dashboard'); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /google_analytics/controllers/dashboard.php: -------------------------------------------------------------------------------- 1 | load->config('google_analytics'); 10 | $config = $this->config->item('google_analytics'); 11 | $this->_validate_user($config['permission'], NULL, FALSE); 12 | $this->load->vars($config); 13 | } 14 | 15 | function index() 16 | { 17 | $this->load->view('google_analytics_dashboard'); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /campaign_monitor/language/english/campaign_monitor_lang.php: -------------------------------------------------------------------------------- 1 | Campaign Moniter campaigns.'; 3 | $lang['campaign_monitor_recipients'] = 'Recipients'; 4 | $lang['campaign_monitor_total_opened'] = 'Total Opened'; 5 | $lang['campaign_monitor_clicks'] = 'Clicks'; 6 | $lang['campaign_monitor_unsubscribed'] = 'Unsubscribed'; 7 | $lang['campaign_monitor_bounced'] = 'Bounced'; 8 | $lang['campaign_monitor_unique_opens'] = 'Unique Opens'; 9 | $lang['campaign_monitor_no_data'] = 'There is currently no campaign data associated with the client %1s.'; -------------------------------------------------------------------------------- /phpmyadmin/views/phpmyadmin_dashboard.php: -------------------------------------------------------------------------------- 1 | 2 | login 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
-------------------------------------------------------------------------------- /wordpress/views/wordpress_dashboard.php: -------------------------------------------------------------------------------- 1 | 2 | login 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
-------------------------------------------------------------------------------- /google_analytics/views/google_analytics_dashboard.php: -------------------------------------------------------------------------------- 1 | 2 | login 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
-------------------------------------------------------------------------------- /clicky/controllers/dashboard.php: -------------------------------------------------------------------------------- 1 | load->config('clicky'); 10 | $config = $this->config->item('clicky'); 11 | $this->_validate_user($config['permission'], NULL, FALSE); 12 | } 13 | 14 | function index() 15 | { 16 | if (!extension_loaded('curl')) show_error(lang('error_no_curl_lib')); 17 | 18 | $vars = $this->config->item('clicky'); 19 | 20 | // scrape html from page running on localhost 21 | $ch = curl_init(); 22 | curl_setopt($ch, CURLOPT_URL, $vars['api']); 23 | curl_setopt($ch, CURLOPT_HEADER, 0); 24 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 25 | $api_data = curl_exec($ch); 26 | curl_close($ch); 27 | 28 | $vars['api_data'] = unserialize($api_data); 29 | $this->load->view('clicky_dashboard', $vars); 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /campaign_monitor/views/campaign_monitor.php: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | 6 | $summary) : ?> 7 |
8 |

9 | 17 |
18 | 19 | 20 |

21 | 22 |
23 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | == FUEL CMS Modules Pack == 2 | This repository contains extra modules not included in the base 3 | installation of FUEL CMS. 4 | 5 | == INSTALLATION == 6 | Move all the downloaded modules folders into your FUEL CMS's fuel/modules 7 | folder. To enable the modules, you must add them to the "modules_allowed" 8 | configuration parameter found in fuel/application/config/MY_fuel.php. Each 9 | module has additional configuration parameters you will need to set in it's 10 | corresponding configuration files. 11 | 12 | == FUEL CMS == 13 | FUEL CMS is a CodeIgniter based Content Management System. To learn more about 14 | it's features visit: 15 | http://www.getfuelcms.com 16 | 17 | FUEL CMS can be downloaded here: 18 | https://github.com/daylightstudio/FUEL-CMS 19 | 20 | 21 | == DOCUMENTATION == 22 | To access the documentation, you can visit: 23 | http://www.getfuelcms.com/user_guide/general/localization/ 24 | 25 | 26 | == TEAM == 27 | * David McReynolds, Daylight Studio, main developer 28 | 29 | 30 | == BUGS == 31 | To file a bug report, go to: 32 | http://github.com/daylightstudio/FUEL-CMS-Modules-Pack/issues 33 | 34 | 35 | == LICENSE == 36 | FUEL CMS and the FUEL CMS Modules Pack is licensed under APACHE 2. 37 | The full text of the license can be found in the 38 | fuel/licenses/fuel_license.txt file. 39 | 40 | -------------------------------------------------------------------------------- /campaign_monitor/config/campaign_monitor.php: -------------------------------------------------------------------------------- 1 | 9 | 10 |
11 | 12 | login 13 | 14 | 15 |

Website Statistics -

16 | 17 |
18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | $val){ ?> 27 | 28 | 29 | 30 | 31 | $val){ 32 | $data = current($val); 33 | ?> 34 | 35 | 36 | 37 | 38 |
39 |
40 | 41 | 42 | -------------------------------------------------------------------------------- /campaign_monitor/controllers/dashboard.php: -------------------------------------------------------------------------------- 1 | _validate_user('tools/campaign_monitor'); 14 | 15 | $this->load->config('campaign_monitor'); 16 | $this->_config = $this->config->item('campaign_monitor'); 17 | 18 | $this->load->library('cache'); 19 | $this->load->module_language(CAMPAIGN_MONITOR_FOLDER, 'campaign_monitor'); 20 | } 21 | 22 | function index() 23 | { 24 | $this->load->module_model(FUEL_FOLDER, 'pages_model'); 25 | $pages = $this->pages_model->all_pages_including_views(TRUE); 26 | 27 | $vars['num_campaigns'] = $this->_config['num_campaigns']; 28 | $vars['account_name'] = $this->_config['account_name']; 29 | $vars['client_name'] = $this->_config['client_name']; 30 | $summaries = array(); 31 | 32 | $cache_id = fuel_cache_id(); 33 | if ($this->_config['use_cache']) 34 | { 35 | $cached_file = $this->cache->get($cache_id, $this->_config['cache_folder']); 36 | if (!empty($cached_file)) $summaries = $cached_file; 37 | } 38 | 39 | if (empty($summaries)) 40 | { 41 | $client_id = $this->_get_client_id(); 42 | if (!empty($client_id)) 43 | { 44 | $campaigns = $this->_get_campaigns($client_id); 45 | if (!empty($campaigns)) 46 | { 47 | foreach($campaigns as $campaign) 48 | { 49 | $summary = $this->_get_campaign_summary($campaign['CampaignID']); 50 | if (!empty($summary)) 51 | { 52 | $summaries[$campaign['Name']] = $summary; 53 | } 54 | } 55 | } 56 | if ($this->_config['use_cache']) 57 | { 58 | $this->cache->save($cache_id, $summaries, $this->_config['cache_folder'], $this->_config['cache_ttl']); 59 | } 60 | } 61 | } 62 | 63 | $vars['summaries'] = $summaries; 64 | if (!is_ajax()) 65 | { 66 | $this->_render('campaign_monitor', $vars); 67 | } 68 | else 69 | { 70 | $this->load->view('campaign_monitor', $vars); 71 | } 72 | } 73 | 74 | function _cm_connect() 75 | { 76 | if (!isset($this->_cm)) 77 | { 78 | require_once(CAMPAIGN_MONITOR_PATH.'libraries/CMBase.php'); 79 | $this->_cm = new CampaignMonitor($this->_config['api_key']); 80 | } 81 | return $this->_cm; 82 | } 83 | 84 | function _get_client_id() 85 | { 86 | $cm = $this->_cm_connect(); 87 | $clients = $cm->userGetClients(); 88 | if (isset($clients['anyType'], $clients['anyType']['Client'])) 89 | { 90 | foreach($clients['anyType']['Client'] as $client) 91 | { 92 | if ($client['Name'] == $this->_config['client_name']) 93 | { 94 | $client_id = $client['ClientID']; 95 | return $client_id; 96 | } 97 | } 98 | } 99 | return NULL; 100 | } 101 | 102 | function _get_campaigns($client_id) 103 | { 104 | $cache_id = 'campaigns'; 105 | $cm = $this->_cm_connect(); 106 | $campaigns = $cm->clientGetCampaigns($client_id); 107 | 108 | if (isset($campaigns['anyType'], $campaigns['anyType']['Campaign'])) 109 | { 110 | return array_slice($campaigns['anyType']['Campaign'], 0, $this->_config['num_campaigns']); 111 | } 112 | return NULL; 113 | } 114 | 115 | function _get_campaign_summary($campaign_id) 116 | { 117 | $cm = $this->_cm_connect(); 118 | $summaries = $cm->campaignGetSummary($campaign_id); 119 | if (isset($summaries['anyType'])) 120 | { 121 | return $summaries['anyType']; 122 | } 123 | return NULL; 124 | } 125 | 126 | } 127 | 128 | /* End of file tools.php */ 129 | /* Location: ./codeigniter/application/modules/tools/controllers/validate.php */ -------------------------------------------------------------------------------- /wordpress/helpers/wordpress_helper.php: -------------------------------------------------------------------------------- 1 | '); 102 | $replace_funcs = array('site_url_wp_safe(', '$CI->'); 103 | 104 | $contents = str_replace($check_funcs, $replace_funcs, $contents); 105 | $contents = eval('?>'.preg_replace("/;*\s*\?>/", "; ?>", str_replace('config->slash_item('base_url').$CI->config->item('index_page'); 163 | } 164 | else 165 | { 166 | $suffix = ($CI->config->item('url_suffix') == FALSE) ? '' : $CI->config->item('url_suffix'); 167 | return $CI->config->slash_item('base_url').$CI->config->slash_item('index_page').preg_replace("|^/*(.+?)/*$|", "\\1", $uri).$suffix; 168 | } 169 | } 170 | 171 | /* End of file wordpress_helper.php */ 172 | /* Location: ./application/helpers/wordpress_helper.php */ -------------------------------------------------------------------------------- /campaign_monitor/libraries/CMBase.php: -------------------------------------------------------------------------------- 1 | and 6 | * Campaign Monitor 7 | * All rights reserved. 8 | * 9 | * This software is licensed under the BSD License: 10 | * 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions are met: 13 | * * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * * Neither the name of Kaiser Shahid or Campaign Monitor nor the 19 | * names of its contributors may be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY Kaiser Shahid "AS IS" AND ANY 23 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | * DISCLAIMED. IN NO EVENT SHALL Kaiser Shahid BE LIABLE FOR ANY 26 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | * 33 | * @package CampaignMonitorLib 34 | */ 35 | 36 | /** 37 | * This is an all-inclusive package for interfacing with Campaign Monitor's services. It 38 | * supports SOAP, GET, and POST seamlessly (just set the $method property to 'soap', 'get', 39 | * or 'post' before making a call) and always returns the same view of data regardless of 40 | * the method used to call the service. 41 | * 42 | * See README for more information on usage and details. 43 | * 44 | * CHANGES: 2008-04-28 45 | * ------------------- 46 | * - Now compatible with PHP4. Biggest changes include removing reliance on 47 | * enhanced OOP syntax, and using XML Parser functions instead of SimpleXML. 48 | * - Base class (CMBase) branches into CampaignMonitor and MailBuild 49 | * - CMBase contains all the shared API calls (and extended functionality 50 | * related to those) between both classes. 51 | * 52 | * @package CampaignMonitorLib 53 | * @subpackage CMBase 54 | * @author Kaiser Shahid (www.qaiser.net) 55 | * @copyright 2007-2009 56 | * @see http://www.campaignmonitor.com/api/ 57 | */ 58 | 59 | define('PHPVER', phpversion()); 60 | define('CM_PHP_WRAPPER_VERSION', '1.4.9'); 61 | 62 | // WARNING: this is needed to keep the socket from apparently hanging (even when it should be done reading) 63 | // NOTE: using a timeout (SOCKET_TIMEOUT) that's passed when calling fsockopen. safer thing to do. 64 | //ini_set( 'default_socket_timeout', 1 ); 65 | define( 'SOCKET_TIMEOUT', 1 ); 66 | 67 | class CMBase 68 | { 69 | var /*@ protected */ 70 | $api = '' 71 | , $campaign_id = 0 72 | , $client_id = 0 73 | , $list_id = 0 74 | ; 75 | 76 | var /*@ public */ 77 | $method = 'get' 78 | , $url = '' 79 | , $soapAction = '' 80 | , $curl = true 81 | , $curlExists = true 82 | ; 83 | 84 | // debugging options 85 | var /*@ public */ 86 | $debug_level = 0 87 | , $debug_request = '' 88 | , $debug_response = '' 89 | , $debug_url = '' 90 | , $debug_info = array() 91 | , $show_response_headers = 0 92 | ; 93 | 94 | /** 95 | * @param string $api Your API key. 96 | * @param string $client The default ClientId you're going to work with. 97 | * @param string $campaign The default CampaignId you're going to work with. 98 | * @param string $list The default ListId you're going to work with. 99 | * @param string $method Determines request type. Values are either get, post, or soap. 100 | */ 101 | function CMBase( $api = null, $client = null, $campaign = null, $list = null, $method = 'get' ) 102 | { 103 | $this->api = $api; 104 | $this->client_id = $client; 105 | $this->campaign_id = $campaign; 106 | $this->list_id = $list; 107 | $this->method = $method; 108 | $this->curlExists = function_exists( 'curl_init' ) && function_exists( 'curl_setopt' ); 109 | } 110 | 111 | /** 112 | * The direct way to make an API call. This allows developers to include new API 113 | * methods that might not yet have a wrapper method as part of the package. 114 | * 115 | * @param string $action The API call. 116 | * @param array $options An associative array of values to send as part of the request. 117 | * @return array The parsed XML of the request. 118 | */ 119 | function makeCall( $action = '', $options = array() ) 120 | { 121 | // NEW [2008-06-24]: switch to soap automatically for these calls 122 | $old_method = $this->method; 123 | if ( $action == 'Subscriber.AddWithCustomFields' || $action == 'Subscriber.AddAndResubscribeWithCustomFields' || $action == 'Campaign.Create') 124 | $this->method = 'soap'; 125 | 126 | if ( !$action ) return null; 127 | $url = $this->url; 128 | 129 | // DONE: like facebook's client, allow for get/post through the file wrappers 130 | // if curl isn't available. (or maybe have curl-emulating functions defined 131 | // at the bottom of this script.) 132 | 133 | //$ch = curl_init(); 134 | if ( !isset( $options['header'] ) ) 135 | $options['header'] = array(); 136 | 137 | $options['header'][] = 'User-Agent: CMBase URL Handler ' . CM_PHP_WRAPPER_VERSION; 138 | 139 | $postdata = ''; 140 | $method = 'GET'; 141 | 142 | if ( $this->method == 'soap' ) 143 | { 144 | $options['header'][] = 'Content-Type: text/xml; charset=utf-8'; 145 | $options['header'][] = 'SOAPAction: "' . $this->soapAction . $action . '"'; 146 | 147 | $postdata = "\n"; 148 | $postdata .= "\n"; 151 | $postdata .= "\n"; 152 | $postdata .= " <{$action} xmlns=\"{$this->soapAction}\">\n"; 153 | $postdata .= " {$this->api}\n"; 154 | 155 | if ( isset( $options['params'] ) ) 156 | $postdata .= $this->array2xml( $options['params'], "\t\t" ); 157 | 158 | $postdata .= " \n"; 159 | $postdata .= "\n"; 160 | $postdata .= ""; 161 | 162 | $method = 'POST'; 163 | 164 | //curl_setopt( $ch, CURLOPT_POST, 1 ); 165 | //curl_setopt( $ch, CURLOPT_POSTFIELDS, $postdata ); 166 | } 167 | else 168 | { 169 | $postdata = "ApiKey={$this->api}"; 170 | $url .= "/{$action}"; 171 | 172 | // NOTE: since this is GET, the assumption is that params is a set of simple key-value pairs. 173 | if ( isset( $options['params'] ) ) 174 | { 175 | foreach ( $options['params'] as $k => $v ) 176 | $postdata .= '&' . $k . '=' .rawurlencode($this->fixEncoding($v)); 177 | } 178 | 179 | if ( $this->method == 'get' ) 180 | { 181 | $url .= '?' . $postdata; 182 | $postdata = ''; 183 | } 184 | else 185 | { 186 | $options['header'][] = 'Content-Type: application/x-www-form-urlencoded'; 187 | $method = 'POST'; 188 | //curl_setopt( $ch, CURLOPT_POST, 1 ); 189 | //curl_setopt( $ch, CURLOPT_POSTFIELDS, $postdata ); 190 | } 191 | } 192 | 193 | $res = ''; 194 | 195 | // WARNING: using fopen() does not recognize stream contexts in PHP 4.x, so 196 | // my guess is using fopen() in PHP 4.x implies that POST is not supported 197 | // (otherwise, how do you tell fopen() to use POST?). tried fsockopen(), but 198 | // response time was terrible. if someone has more experience with working 199 | // directly with streams, please troubleshoot that. 200 | // NOTE: fsockopen() needs a small timeout to force the socket to close. 201 | // it's defined in SOCKET_TIMEOUT. 202 | 203 | // preferred method is curl, only if it exists and $this->curl is true. 204 | if ( $this->curl && $this->curlExists ) 205 | { 206 | $ch = curl_init(); 207 | if ( $this->method != 'get' ) 208 | { 209 | curl_setopt( $ch, CURLOPT_POST, 1 ); 210 | curl_setopt( $ch, CURLOPT_POSTFIELDS, $postdata ); 211 | } 212 | 213 | curl_setopt( $ch, CURLOPT_URL, $url ); 214 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); 215 | curl_setopt( $ch, CURLOPT_HTTPHEADER, $options['header'] ); 216 | curl_setopt( $ch, CURLOPT_HEADER, $this->show_response_headers ); 217 | 218 | // except for the response, all other information will be stored when debugging is on. 219 | $res = curl_exec( $ch ); 220 | if ( $this->debug_level ) 221 | { 222 | $this->debug_url = $url; 223 | $this->debug_request = $postdata; 224 | $this->debug_info = curl_getinfo( $ch ); 225 | $this->debug_info['headers_sent'] = $options['header']; 226 | } 227 | $this->debug_response = $res; 228 | curl_close( $ch ); 229 | } 230 | else 231 | { 232 | // 'header' is actually the entire HTTP payload. as such, you need 233 | // Content-Length header, otherwise you'll get errors returned/emitted. 234 | 235 | $postLen = strlen( $postdata ); 236 | $ctx = array( 237 | 'method' => $method 238 | , 'header' => implode( "\n", $options['header'] ) 239 | . "\nContent-Length: " . $postLen 240 | . "\n\n" . $postdata 241 | ); 242 | 243 | if ( $this->debug_level ) 244 | { 245 | $this->debug_url = $url; 246 | $this->debug_request = $postdata; 247 | $this->debug_info['overview'] = 'Used stream_context_create()/fopen() to make request. Content length=' . $postLen; 248 | $this->debug_info['headers_sent'] = $options['header']; 249 | //$this->debug_info['complete_content'] = $ctx; 250 | } 251 | 252 | $pv = PHPVER; 253 | 254 | // the preferred non-cURL way if user is using PHP 5.x 255 | if ( $pv{0} == '5' ) 256 | { 257 | $context = stream_context_create( array( 'http' => $ctx ) ); 258 | $fp = fopen( $url, 'r', false, $context ); 259 | ob_start(); 260 | fpassthru( $fp ); 261 | fclose( $fp ); 262 | $res = ob_get_clean(); 263 | } 264 | else 265 | { 266 | // this should work with PHP 4, but it seems to take forever to get data back this way 267 | // NOTE: setting the default_socket_timeout seems to alleviate this issue [finally]. 268 | list( $protocol, $url ) = explode( '//', $url, 2 ); 269 | list( $domain, $path ) = explode( '/', $url, 2 ); 270 | $fp = fsockopen( $domain, 80, $tvar, $tvar2, SOCKET_TIMEOUT ); 271 | 272 | if ( $fp ) 273 | { 274 | $payload = "$method /$path HTTP/1.1\n" 275 | . "Host: $domain\n" 276 | . $ctx['header'] 277 | ; 278 | fwrite( $fp, $payload ); 279 | 280 | // even with the socket timeout set, using fgets() isn't playing nice, but 281 | // fpassthru() seems to be doing the right thing. 282 | 283 | ob_start(); 284 | fpassthru( $fp ); 285 | list( $headers, $res ) = explode( "\r\n\r\n", ob_get_clean(), 2 ); 286 | 287 | if ( $this->debug_level ) 288 | $this->debug_info['headers_received'] = $headers; 289 | 290 | fclose( $fp ); 291 | } 292 | elseif ( $this->debug_level ) 293 | $this->debug_info['overview'] .= "\nOpening $domain/$path failed!"; 294 | } 295 | } 296 | 297 | if ( $res ) 298 | { 299 | if ( $this->method == 'soap' ) 300 | { 301 | $tmp = $this->xml2array( $res, '/soap:Envelope/soap:Body' ); 302 | if ( !is_array( $tmp ) ) 303 | return $tmp; 304 | else 305 | return $tmp[$action.'Response'][$action.'Result']; 306 | } 307 | else 308 | return $this->xml2array($res); 309 | } 310 | else 311 | return null; 312 | } 313 | 314 | /** 315 | * Encodes a string to UTF-8 only if needed 316 | * @param $in_str String to potentially encode 317 | * @return UTF-8 encoded string 318 | */ 319 | function fixEncoding($in_str) { 320 | $cur_encoding = mb_detect_encoding($in_str); 321 | if($cur_encoding == "UTF-8" && mb_check_encoding($in_str,"UTF-8")) 322 | return $in_str; 323 | else 324 | return utf8_encode($in_str); 325 | } 326 | 327 | /** 328 | * Convert the given XML $contents into a PHP array. Based on code from: 329 | * http://www.bin-co.com/php/scripts/xml2array/ 330 | * @param $contents The XML to be converted. 331 | * @param $root The path of the root element within the XML at which 332 | * conversion should occur. 333 | * @param $charset The character set to use. 334 | * @param $get_attributes 0 or 1. If this is 1 the function will get the 335 | * attributes as well as the tag values - this results in a different array 336 | * structure in the return value. 337 | * @param $priority Can be 'tag' or 'attribute'. This will change the structure 338 | * of the resulting array. For 'tag', the tags are given more importance. 339 | * @return A PHP array representing the XML $contents passed in 340 | */ 341 | function xml2array( 342 | $contents, 343 | $root = '/', 344 | $charset = 'utf-8', 345 | $get_attributes = 0, 346 | $priority = 'tag') { 347 | 348 | if(!$contents) 349 | return array(); 350 | 351 | if(!function_exists('xml_parser_create')) 352 | return array(); 353 | 354 | // Get the PHP XML parser 355 | $parser = xml_parser_create($charset); 356 | 357 | // Attempt to find the last tag in the $root path and use this as the 358 | // start/end tag for the process of extracting the xml 359 | // Example input: '/soap:Envelope/soap:Body' 360 | 361 | // Toggles whether the extraction of xml into the array actually occurs 362 | $extract_on = TRUE; 363 | $start_and_end_element_name = ''; 364 | $root_elements = explode('/', $root); 365 | if ($root_elements != FALSE && 366 | !empty($root_elements)) { 367 | $start_and_end_element_name = trim(end($root_elements)); 368 | if (!empty($start_and_end_element_name)) 369 | $extract_on = FALSE; 370 | } 371 | 372 | xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); # http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss 373 | xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); 374 | xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); 375 | xml_parse_into_struct($parser, trim($contents), $xml_values); 376 | xml_parser_free($parser); 377 | 378 | if(!$xml_values) 379 | return; 380 | 381 | $xml_array = array(); 382 | $parents = array(); 383 | $opened_tags = array(); 384 | $arr = array(); 385 | 386 | $current = &$xml_array; // Reference 387 | 388 | // Go through the tags. 389 | $repeated_tag_index = array(); // Multiple tags with same name will be turned into an array 390 | foreach($xml_values as $data) { 391 | unset($attributes,$value); // Remove existing values, or there will be trouble 392 | 393 | // This command will extract these variables into the foreach scope 394 | // tag(string), type(string), level(int), attributes(array). 395 | extract($data); 396 | 397 | if (!empty($start_and_end_element_name) && 398 | $tag == $start_and_end_element_name) { 399 | // Start at the next element (if looking at the opening tag), 400 | // or don't process any more elements (if looking at the closing tag)... 401 | $extract_on = !$extract_on; 402 | continue; 403 | } 404 | 405 | if (!$extract_on) 406 | continue; 407 | 408 | $result = array(); 409 | $attributes_data = array(); 410 | 411 | if(isset($value)) { 412 | if($priority == 'tag') $result = $value; 413 | else $result['value'] = $value; //Put the value in a assoc array if we are in the 'Attribute' mode 414 | } 415 | 416 | // Set the attributes too. 417 | if(isset($attributes) and $get_attributes) { 418 | foreach($attributes as $attr => $val) { 419 | if($priority == 'tag') $attributes_data[$attr] = $val; 420 | else $result['attr'][$attr] = $val; // Set all the attributes in a array called 'attr' 421 | } 422 | } 423 | 424 | // See tag status and do the needed. 425 | if($type == "open") {// The starting of the tag '' 426 | $parent[$level-1] = &$current; 427 | if(!is_array($current) or (!in_array($tag, array_keys($current)))) { //Insert New tag 428 | $current[$tag] = $result; 429 | if($attributes_data) $current[$tag. '_attr'] = $attributes_data; 430 | $repeated_tag_index[$tag.'_'.$level] = 1; 431 | $current = &$current[$tag]; 432 | } else { // There was another element with the same tag name 433 | if(isset($current[$tag][0])) { // If there is a 0th element it is already an array 434 | $current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result; 435 | $repeated_tag_index[$tag.'_'.$level]++; 436 | } else { // This section will make the value an array if multiple tags with the same name appear together 437 | $current[$tag] = array($current[$tag],$result); // This will combine the existing item and the new item together to make an array 438 | $repeated_tag_index[$tag.'_'.$level] = 2; 439 | 440 | if(isset($current[$tag.'_attr'])) { // The attribute of the last(0th) tag must be moved as well 441 | $current[$tag]['0_attr'] = $current[$tag.'_attr']; 442 | unset($current[$tag.'_attr']); 443 | } 444 | } 445 | $last_item_index = $repeated_tag_index[$tag.'_'.$level]-1; 446 | $current = &$current[$tag][$last_item_index]; 447 | } 448 | } elseif($type == "complete") { // Tags that ends in 1 line '' 449 | // See if the key is already taken. 450 | if(!isset($current[$tag])) { //New Key 451 | // Don't insert an empty array - we don't want it! 452 | if (!(is_array($result) && empty($result))) 453 | $current[$tag] = $result; 454 | $repeated_tag_index[$tag.'_'.$level] = 1; 455 | if($priority == 'tag' and $attributes_data) $current[$tag. '_attr'] = $attributes_data; 456 | 457 | } else { // If taken, put all things inside a list(array) 458 | if(isset($current[$tag][0]) and is_array($current[$tag])) { // If it is already an array... 459 | 460 | // ...push the new element into that array. 461 | $current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result; 462 | 463 | if($priority == 'tag' and $get_attributes and $attributes_data) { 464 | $current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data; 465 | } 466 | $repeated_tag_index[$tag.'_'.$level]++; 467 | 468 | } else { // If it is not an array... 469 | $current[$tag] = array($current[$tag],$result); // ...Make it an array using using the existing value and the new value 470 | $repeated_tag_index[$tag.'_'.$level] = 1; 471 | if($priority == 'tag' and $get_attributes) { 472 | if(isset($current[$tag.'_attr'])) { // The attribute of the last(0th) tag must be moved as well 473 | 474 | $current[$tag]['0_attr'] = $current[$tag.'_attr']; 475 | unset($current[$tag.'_attr']); 476 | } 477 | 478 | if($attributes_data) { 479 | $current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data; 480 | } 481 | } 482 | $repeated_tag_index[$tag.'_'.$level]++; // 0 and 1 index is already taken 483 | } 484 | } 485 | } elseif($type == 'close') { // End of tag '' 486 | $current = &$parent[$level-1]; 487 | } 488 | } 489 | return($xml_array); 490 | } 491 | 492 | /** 493 | * Converts an array to XML. This is the inverse to xml2array(). Values 494 | * are automatically escaped with htmlentities(), so you don't need to escape 495 | * values ahead of time. If you have, just set the third parameter to false. 496 | * This is an all-or-nothing deal. 497 | * 498 | * @param mixed $arr The associative to convert to an XML fragment 499 | * @param string $indent (Optional) Starting identation of each element 500 | * @param string $escape (Optional) Determines whether or not to escape a text node. 501 | * @return string An XML fragment. 502 | */ 503 | function array2xml( $arr, $indent = '', $escape = true ) 504 | { 505 | $buff = ''; 506 | 507 | foreach ( $arr as $k => $v ) 508 | { 509 | // Dreamweaver has a bug which causes "/" to be stripped out of "" 510 | // when editing PHP files, so variable parsing is not longer being used 511 | // where a forward slash is required before the variable 512 | if ( !is_array( $v ) ) 513 | $buff .= "$indent<$k>" . ($escape ? $this->fixEncoding(htmlspecialchars($v)) : $v ) . "\n"; 514 | else 515 | { 516 | /* 517 | Encountered a list. The primary difference between the two branches is that 518 | in the 'if' branch, a $k element is generated for each item in $v, whereas 519 | in the 'else' branch, a single $k element encapsulates $v. 520 | */ 521 | 522 | if ( isset( $v[0] ) ) 523 | { 524 | foreach ( $v as $_k => $_v ) 525 | { 526 | if ( is_array( $_v ) ) 527 | $buff .= "$indent<$k>\n" . $this->array2xml( $_v, $indent . "\t", $escape ) . "$indent\n"; 528 | else 529 | $buff .= "$indent<$k>" . ($escape ? $this->fixEncoding(htmlspecialchars($_v)) : $_v ) . "\n"; 530 | } 531 | } 532 | else 533 | $buff .= "$indent<$k>\n" . $this->array2xml( $v, $indent . "\t", $escape ) . "$indent\n"; 534 | } 535 | } 536 | 537 | return $buff; 538 | } 539 | } 540 | 541 | /** 542 | * The new CampaignMonitor class that now extends from CMBase. This should be 543 | * backwards compatible with the original (PHP5) version. 544 | * 545 | * @package CampaignMonitorLib 546 | * @subpackage CampaignMonitor 547 | * @author Kaiser Shahid (www.qaiser.net) and 548 | * Campaign Monitor 549 | * @copyright 2007-2009 550 | * @see http://www.campaignmonitor.com/api/ 551 | */ 552 | class CampaignMonitor extends CMBase 553 | { 554 | var /*@ protected */ 555 | $url = 'http://api.createsend.com/api/api.asmx', 556 | $soapAction = 'http://api.createsend.com/api/'; 557 | 558 | /** 559 | * @param string $api Your API key. 560 | * @param string $client The default ClientId you're going to work with. 561 | * @param string $campaign The default CampaignId you're going to work with. 562 | * @param string $list The default ListId you're going to work with. 563 | * @param string $method Determines request type. Values are either get, post, or soap. 564 | */ 565 | 566 | function CampaignMonitor( $api = null, $client = null, $campaign = null, $list = null, $method = 'get' ) 567 | { 568 | CMBase::CMBase( $api, $client, $campaign, $list, $method ); 569 | } 570 | 571 | /** 572 | * Wrapper for Subscribers.GetActive. This method triples as Subscribers.GetUnsubscribed 573 | * and Subscribers.GetBounced when the very last parameter is overridden. 574 | * 575 | * @param mixed $date If a string, should be in the date() format of 'Y-m-d H:i:s', otherwise, a Unix timestamp. 576 | * @param int $list_id (Optional) A valid List ID to check against. If not given, the default class property is used. 577 | * @param string $action (Optional) Set the actual API method to call. Defaults to Subscribers.GeActive if no other valid value is given. 578 | * @return mixed A parsed response from the server, or null if something failed. 579 | * @see http://www.campaignmonitor.com/api/Subscribers.GetActive.aspx 580 | */ 581 | function subscribersGetActive( $date = 0, $list_id = null, $action = 'Subscribers.GetActive' ) 582 | { 583 | if ( !$list_id ) 584 | $list_id = $this->list_id; 585 | 586 | if ( is_numeric( $date ) ) 587 | $date = date( 'Y-m-d H:i:s', $date ); 588 | 589 | $valid_actions = array( 'Subscribers.GetActive' => '', 'Subscribers.GetUnsubscribed' => '', 'Subscribers.GetBounced' => '' ); 590 | if ( !isset( $valid_actions[$action] ) ) 591 | $action = 'Subscribers.GetActive'; 592 | 593 | return $this->makeCall( $action 594 | , array( 595 | 'params' => array( 596 | 'ListID' => $list_id 597 | , 'Date' => $date 598 | ) 599 | ) 600 | ); 601 | } 602 | 603 | /** 604 | * @param mixed $date If a string, should be in the date() format of 'Y-m-d H:i:s', otherwise, a Unix timestamp. 605 | * @param int $list_id (Optional) A valid List ID to check against. If not given, the default class property is used. 606 | * @see http://www.campaignmonitor.com/api/Subscribers.GetUnsubscribed.aspx 607 | */ 608 | function subscribersGetUnsubscribed( $date = 0, $list_id = null ) 609 | { 610 | return $this->subscribersGetActive( $date, $list_id, 'Subscribers.GetUnsubscribed' ); 611 | } 612 | 613 | /** 614 | * @param mixed $date If a string, should be in the date() format of 'Y-m-d H:i:s', otherwise, a Unix timestamp. 615 | * @param int $list_id (Optional) A valid List ID to check against. If not given, the default class property is used. 616 | * @see http://www.campaignmonitor.com/api/Subscribers.GetBounced.aspx 617 | */ 618 | function subscribersGetBounced( $date = 0, $list_id = null ) 619 | { 620 | return $this->subscribersGetActive( $date, $list_id, 'Subscribers.GetBounced' ); 621 | } 622 | 623 | /** 624 | * subscriberAdd() 625 | * @param string $email Email address. 626 | * @param string $name User's name. 627 | * @param int $list_id (Optional) A valid List ID to check against. If not given, the default class property is used. 628 | * @param boolean $resubscribe If true, does an equivalent 'AndResubscribe' API method. 629 | * @see http://www.campaignmonitor.com/api/Subscriber.Add.aspx 630 | */ 631 | function subscriberAdd( $email, $name, $list_id = null, $resubscribe = false ) 632 | { 633 | if ( !$list_id ) 634 | $list_id = $this->list_id; 635 | 636 | $action = 'Subscriber.Add'; 637 | if ( $resubscribe ) $action = 'Subscriber.AddAndResubscribe'; 638 | 639 | return $this->makeCall( $action 640 | , array( 641 | 'params' => array( 642 | 'ListID' => $list_id 643 | , 'Email' => $email 644 | , 'Name' => $name 645 | ) 646 | ) 647 | ); 648 | } 649 | 650 | /** 651 | * This encapsulates the check of whether this particular user unsubscribed once. 652 | * @param string $email Email address. 653 | * @param string $name User's name. 654 | * @param int $list_id (Optional) A valid List ID to check against. If not given, the default class property is used. 655 | */ 656 | function subscriberAddRedundant( $email, $name, $list_id = null ) 657 | { 658 | $added = $this->subscriberAdd( $email, $name, $list_id ); 659 | 660 | if ( $added && $added['Result']['Code'] == '204' ) 661 | { 662 | $subscribed = $this->subscribersGetIsSubscribed( $email, $list_id ); 663 | 664 | // Must have unsubscribed, so resubscribe 665 | if ( $subscribed['anyType'] == 'False' ) 666 | { 667 | // since we're internal, we'll just call the method with full parameters rather 668 | // than go through a secondary wrapper function. 669 | $added = $this->subscriberAdd( $email, $name, $list_id, true ); 670 | return $added; 671 | } 672 | } 673 | 674 | return $added; 675 | } 676 | 677 | /** 678 | * @param string $email Email address. 679 | * @param string $name User's name. 680 | * @param mixed $fields Should be a $key => $value mapping. If there are more than one items for $key, let 681 | * $value be a list of scalar values. Example: array( 'Interests' => array( 'xbox', 'wii' ) ) 682 | * @param int $list_id (Optional) A valid List ID to check against. If not given, the default class property is used. 683 | * @param boolean $resubscribe If true, does an equivalent 'AndResubscribe' API method. 684 | * @return mixed A parsed response from the server, or null if something failed. 685 | * @see http://www.campaignmonitor.com/api/Subscriber.AddWithCustomFields.aspx 686 | */ 687 | function subscriberAddWithCustomFields( $email, $name, $fields, $list_id = null, $resubscribe = false ) 688 | { 689 | if ( !$list_id ) 690 | $list_id = $this->list_id; 691 | 692 | $action = 'Subscriber.AddWithCustomFields'; 693 | if ( $resubscribe ) $action = 'Subscriber.AddAndResubscribeWithCustomFields'; 694 | 695 | if ( !is_array( $fields ) ) 696 | $fields = array(); 697 | 698 | $_fields = array( 'SubscriberCustomField' => array() ); 699 | foreach ( $fields as $k => $v ) 700 | { 701 | if ( is_array( $v ) ) 702 | { 703 | foreach ( $v as $nv ) 704 | $_fields['SubscriberCustomField'][] = array( 'Key' => $k, 'Value' => $nv ); 705 | } 706 | else 707 | $_fields['SubscriberCustomField'][] = array( 'Key' => $k, 'Value' => $v ); 708 | } 709 | return $this->makeCall( $action 710 | , array( 711 | 'params' => array( 712 | 'ListID' => $list_id 713 | , 'Email' => $email 714 | , 'Name' => $name 715 | , 'CustomFields' => $_fields 716 | ) 717 | ) 718 | ); 719 | } 720 | 721 | /** 722 | * Same as subscriberAddRedundant() except with CustomFields. 723 | * 724 | * @param string $email Email address. 725 | * @param string $name User's name. 726 | * @param int $list_id (Optional) A valid List ID to check against. If not given, the default class property is used. 727 | * @return mixed A parsed response from the server, or null if something failed. 728 | */ 729 | function subscriberAddWithCustomFieldsRedundant( $email, $name, $fields, $list_id = null ) 730 | { 731 | $added = $this->subscriberAddWithCustomFields( $email, $name, $fields, $list_id ); 732 | if ( $added && $added['Code'] == '0' ) 733 | { 734 | $subscribed = $this->subscribersGetIsSubscribed( $email ); 735 | if ( $subscribed == 'False' ) 736 | { 737 | $added = $this->subscriberAddWithCustomFields( $email, $name, $fields, $list_id, true ); 738 | return $added; 739 | } 740 | } 741 | 742 | return $added; 743 | } 744 | 745 | /** 746 | * @param string $email Email address. 747 | * @param int $list_id (Optional) A valid List ID to check against. If not given, the default class property is used. 748 | * @param boolean $check_subscribed If true, does the Subscribers.GetIsSubscribed API method instead. 749 | * @return mixed A parsed response from the server, or null if something failed. 750 | * @see http://www.campaignmonitor.com/api/Subscriber.Unsubscribe.aspx 751 | */ 752 | function subscriberUnsubscribe( $email, $list_id = null, $check_subscribed = false ) 753 | { 754 | if ( !$list_id ) 755 | $list_id = $this->list_id; 756 | 757 | $action = 'Subscriber.Unsubscribe'; 758 | if ( $check_subscribed ) $action = 'Subscribers.GetIsSubscribed'; 759 | 760 | return $this->makeCall( $action 761 | , array( 762 | 'params' => array( 763 | 'ListID' => $list_id 764 | , 'Email' => $email 765 | ) 766 | ) 767 | ); 768 | } 769 | 770 | /** 771 | * @return string A parsed response from the server, or null if something failed. 772 | * @see http://www.campaignmonitor.com/api/Subscribers.GetIsSubscribed.aspx 773 | */ 774 | function subscribersGetIsSubscribed( $email, $list_id = null ) 775 | { 776 | return $this->subscriberUnsubscribe( $email, $list_id, true ); 777 | } 778 | 779 | /** 780 | * Given an array of lists, indicate whether the $email is subscribed to each of those lists. 781 | * 782 | * @param string $email User's email 783 | * @param mixed $lists An associative array of lists to check against. Each key should be a List ID 784 | * @param boolean $no_assoc If true, only returns an array where each value indicates that the user is subscribed 785 | * to that particular list. Otherwise, returns a fully associative array of $list_id => true | false. 786 | * @return mixed An array corresponding to $lists where true means the user is subscribed to that particular list. 787 | */ 788 | function checkSubscriptions( $email, $lists, $no_assoc = true ) 789 | { 790 | $nlist = array(); 791 | foreach ( $lists as $lid => $misc ) 792 | { 793 | $val = $this->subscribersGetIsSubscribed( $email, $lid ); 794 | $val = $val != 'False'; 795 | if ( $no_assoc && $val ) $nlist[] = $lid; 796 | elseif ( !$no_assoc ) $nlist[$lid] = $val; 797 | } 798 | 799 | return $nlist; 800 | } 801 | 802 | /** 803 | * @param string $email Email address. 804 | * @param string $name User's name. 805 | * @param int $list_id (Optional) A valid List ID to check against. If not given, the default class property is used. 806 | * @see http://www.campaignmonitor.com/api/Subscriber.AddAndResubscribe.aspx 807 | */ 808 | 809 | function subscriberAddAndResubscribe( $email, $name, $list_id = null ) 810 | { 811 | return $this->subscriberAdd( $email, $name, $list_id, true ); 812 | } 813 | 814 | /** 815 | * @param string $email Email address. 816 | * @param string $name User's name. 817 | * @param mixed $fields Should only be a single-dimension array of key-value pairs. 818 | * @param int $list_id (Optional) A valid List ID to check against. If not given, the default class property is used. 819 | * @param boolean $resubscribe If true, does an equivalent 'AndResubscribe' API method. 820 | * @return mixed A parsed response from the server, or null if something failed. 821 | * @see http://www.campaignmonitor.com/api/Subscriber.AddAndResubscribeWithCustomFields.aspx 822 | */ 823 | 824 | function subscriberAddAndResubscribeWithCustomFields( $email, $name, $fields, $list_id = null ) 825 | { 826 | return $this->subscriberAddWithCustomFields( $email, $name, $fields, $list_id, true ); 827 | } 828 | 829 | /** 830 | * Returns the details of a particular subscriber. 831 | * @param $list_id The ID of the list to which the subscriber belongs 832 | * @param $email The subscriber's email address 833 | * @return mixed A parsed response from the server, or null if something failed 834 | * @see http://www.campaignmonitor.com/api/method/subscribers-get-single-subscriber/ 835 | */ 836 | function subscriberGetSingleSubscriber($list_id = null, $email) 837 | { 838 | if (!$list_id != null) 839 | $list_id = $this->list_id; 840 | 841 | return $this->makeCall( 842 | 'Subscribers.GetSingleSubscriber', 843 | array( 844 | 'params' => array( 845 | 'ListID' => $list_id, 846 | 'EmailAddress' => $email 847 | ) 848 | ) 849 | ); 850 | } 851 | 852 | /* 853 | * A generic wrapper to feed Client.* calls. 854 | * 855 | * @param string $method The API method to call. 856 | * @param int $client_id (Optional) A valid Client ID to check against. If not given, the default class property is used. 857 | * @return mixed A parsed response from the server, or null if something failed. 858 | */ 859 | 860 | function clientGeneric( $method, $client_id = null ) 861 | { 862 | if ( !$client_id ) 863 | $client_id = $this->client_id; 864 | 865 | return $this->makeCall( 'Client.' . $method 866 | , array( 867 | 'params' => array( 868 | 'ClientID' => $client_id 869 | ) 870 | ) 871 | ); 872 | } 873 | 874 | /** 875 | * @param int $client_id (Optional) A valid Client ID to check against. If not given, the default class property is used. 876 | * @return mixed A parsed response from the server, or null if something failed. 877 | * @see http://www.campaignmonitor.com/api/Client.GetLists.aspx 878 | */ 879 | 880 | function clientGetLists( $client_id = null ) 881 | { 882 | return $this->clientGeneric( 'GetLists', $client_id ); 883 | } 884 | 885 | /** 886 | * Creates an associative array with list_id => List_label pairings. 887 | * 888 | * @param int $client_id (Optional) A valid Client ID to check against. If not given, the default class property is used. 889 | */ 890 | 891 | function clientGetListsDropdown( $client_id = null ) 892 | { 893 | $lists = $this->clientGetLists( $client_id ); 894 | if ( !isset( $lists['List'] ) ) 895 | return null; 896 | else 897 | $lists = $lists['List']; 898 | 899 | $_lists = array(); 900 | 901 | if ( isset( $lists[0] ) ) 902 | { 903 | foreach ( $lists as $list ) 904 | $_lists[$list['ListID']] = $list['Name']; 905 | } 906 | else 907 | $_lists[$lists['ListID']] = $lists['Name']; 908 | 909 | return $_lists; 910 | } 911 | 912 | /** 913 | * Creates an associative array with list_id:List_Label => (list_id) List_label pairings. 914 | * Remember that you'll need to split the key on ':' only once to get the appropriate ListID 915 | * and Segment Name. 916 | * 917 | * @param int $client_id (Optional) A valid Client ID to check against. If not given, the default class property is used. 918 | */ 919 | 920 | function clientGetSegmentsDropdown( $client_id = null ) 921 | { 922 | $lists = $this->clientGetSegments( $client_id ); 923 | if ( !isset( $lists['List'] ) ) 924 | return null; 925 | else 926 | $lists = $lists['List']; 927 | 928 | $_lists = array(); 929 | 930 | if ( isset( $lists[0] ) ) 931 | { 932 | foreach ( $lists as $list ) 933 | $_lists[$list['ListID'].':'.$list['Name']] = '(' . $list['ListID'] . ') ' . $list['Name']; 934 | } 935 | else 936 | $_lists[$lists['ListID'].':'.$lists['Name']] = '(' . $lists['ListID'] . ') ' . $lists['Name']; 937 | 938 | return $_lists; 939 | } 940 | 941 | /** 942 | * @param int $client_id (Optional) A valid Client ID to check against. If not given, the default class property is used. 943 | * @return mixed A parsed response from the server, or null if something failed. 944 | * @see http://www.campaignmonitor.com/api/Client.GetCampaigns.aspx 945 | */ 946 | 947 | function clientGetCampaigns( $client_id = null ) 948 | { 949 | return $this->clientGeneric( 'GetCampaigns', $client_id ); 950 | } 951 | 952 | /** 953 | * @param int $client_id (Optional) A valid Client ID to check against. If not given, the default class property is used. 954 | * @return mixed A parsed response from the server, or null if something failed. 955 | * @see http://www.campaignmonitor.com/api/Client.GetSegments.aspx 956 | */ 957 | 958 | function clientGetSegments( $client_id = null ) 959 | { 960 | return $this->clientGeneric( 'GetSegments', $client_id ); 961 | } 962 | 963 | /** 964 | * @param int $client_id (Optional) A valid Client ID to check against. If not given, the default class property is used. 965 | * @return mixed A parsed response from the server, or null if something failed. 966 | * @see http://www.campaignmonitor.com/api/method/client-getsuppressionlist/ 967 | */ 968 | function clientGetSuppressionList( $client_id = null ) 969 | { 970 | return $this->clientGeneric( 'GetSuppressionList', $client_id ); 971 | } 972 | 973 | /** 974 | * @param int $client_id (Optional) A valid Client ID to check against. If not given, the default class property is used. 975 | * @return mixed A parsed response from the server, or null if something failed. 976 | * @see http://www.campaignmonitor.com/api/method/client-gettemplates/ 977 | */ 978 | function clientGetTemplates( $client_id = null ) 979 | { 980 | return $this->clientGeneric( 'GetTemplates', $client_id ); 981 | } 982 | 983 | /** 984 | * @param int $client_id (Optional) A valid Client ID to check against. If not given, the default class property is used. 985 | * @return mixed A parsed response from the server, or null if something failed. 986 | * @see http://www.campaignmonitor.com/api/method/client-getdetail/ 987 | */ 988 | function clientGetDetail( $client_id = null ) 989 | { 990 | return $this->clientGeneric( 'GetDetail', $client_id ); 991 | } 992 | 993 | /** 994 | * @param string $companyName (CompanyName) Company name of the client to be added 995 | * @param string $contactName (ContactName) Contact name of the client to be added 996 | * @param string $emailAddress (EmailAddress) Email Address of the client to be added 997 | * @param string $country (Country) Country of the client to be added 998 | * @param string $timezone (Timezone) Timezone of the client to be added 999 | * @return mixed A parsed response from the server, or null if something failed. 1000 | * @see http://www.campaignmonitor.com/api/method/client-create/ 1001 | */ 1002 | function clientCreate( $companyName, $contactName, $emailAddress, $country, $timezone ) 1003 | { 1004 | return $this->makeCall( 'Client.Create' 1005 | , array( 1006 | 'params' => array( 1007 | 'CompanyName' => $companyName 1008 | , 'ContactName' => $contactName 1009 | , 'EmailAddress' => $emailAddress 1010 | , 'Country' => $country 1011 | , 'Timezone' => $timezone 1012 | ) 1013 | ) 1014 | ); 1015 | } 1016 | 1017 | /** 1018 | * @param int $client_id (ClientID) ID of the client to be updated 1019 | * @param string $companyName (CompanyName) Company name of the client to be updated 1020 | * @param string $contactName (ContactName) Contact name of the client to be updated 1021 | * @param string $emailAddress (EmailAddress) Email Address of the client to be updated 1022 | * @param string $country (Country) Country of the client to be updated 1023 | * @param string $timezone (Timezone) Timezone of the client to be updated 1024 | * @return mixed A parsed response from the server, or null if something failed. 1025 | * @see http://www.campaignmonitor.com/api/method/client-create/ 1026 | */ 1027 | function clientUpdateBasics( $client_id, $companyName, $contactName, $emailAddress, $country, $timezone ) 1028 | { 1029 | return $this->makeCall( 'Client.UpdateBasics' 1030 | , array( 1031 | 'params' => array( 1032 | 'ClientID' => $client_id 1033 | , 'CompanyName' => $companyName 1034 | , 'ContactName' => $contactName 1035 | , 'EmailAddress' => $emailAddress 1036 | , 'Country' => $country 1037 | , 'Timezone' => $timezone 1038 | ) 1039 | ) 1040 | ); 1041 | } 1042 | 1043 | /** 1044 | * @param int $client_id (ClientID) ID of the client to be updated 1045 | * @param string $accessLevel (AccessLevel) AccessLevel of the client 1046 | * @param string $username (Username) Clients username 1047 | * @param string $password (Password) Password of the client 1048 | * @param string $billingType (BillingType) BillingType that the client will be set as 1049 | * @param string $currency (Currency) Currency that the client will pay in 1050 | * @param string $deliveryFee (DeliveryFee) Per campaign deliivery fee for the campaign 1051 | * @param string $costPerRecipient (CostPerRecipient) Per email fee for the client 1052 | * @param string $designAndSpamTestFee (DesignAndSpamTestFee) Amount the client will 1053 | * be charged if they have access to send design/spam tests 1054 | * @return mixed A parsed response from the server, or null if something failed. 1055 | * @see http://www.campaignmonitor.com/api/method/client-updateaccessandbilling/ 1056 | */ 1057 | function clientUpdateAccessAndBilling( $client_id, $accessLevel, $username, $password, $billingType, $currency, $deliveryFee, $costPerRecipient, $designAndSpamTestFee ) 1058 | { 1059 | return $this->makeCall( 'Client.UpdateAccessAndBilling' 1060 | , array( 1061 | 'params' => array( 1062 | 'ClientID' => $client_id 1063 | , 'AccessLevel' => $accessLevel 1064 | , 'Username' => $username 1065 | , 'Password' => $password 1066 | , 'BillingType' => $billingType 1067 | , 'Currency' => $currency 1068 | , 'DeliveryFee' => $deliveryFee 1069 | , 'CostPerRecipient' => $costPerRecipient 1070 | , 'DesignAndSpamTestFee' => $designAndSpamTestFee 1071 | ) 1072 | ) 1073 | ); 1074 | } 1075 | 1076 | 1077 | 1078 | /** 1079 | * @return mixed A parsed response from the server, or null if something failed. 1080 | * @see http://www.campaignmonitor.com/api/User.GetClients.aspx 1081 | */ 1082 | 1083 | function userGetClients() 1084 | { 1085 | return $this->makeCall( 'User.GetClients' ); 1086 | } 1087 | 1088 | /** 1089 | * @return string A parsed response from the server, or null if something failed. 1090 | * @see http://www.campaignmonitor.com/api/User.GetSystemDate.aspx 1091 | */ 1092 | 1093 | function userGetSystemDate() 1094 | { 1095 | return $this->makeCall( 'User.GetSystemDate' ); 1096 | } 1097 | 1098 | /** 1099 | * @return string A parsed response from the server, or null if something failed. 1100 | * @see http://www.campaignmonitor.com/api/method/user-gettimezones/ 1101 | */ 1102 | 1103 | function userGetTimezones() 1104 | { 1105 | return $this->makeCall( 'User.GetTimezones' ); 1106 | } 1107 | 1108 | /** 1109 | * @return string A parsed response from the server, or null if something failed. 1110 | * @see http://www.campaignmonitor.com/api/method/user-getcountries/ 1111 | */ 1112 | 1113 | function userGetCountries() 1114 | { 1115 | return $this->makeCall( 'User.GetCountries' ); 1116 | } 1117 | 1118 | /** 1119 | * Gets the API key for a Campaign Monitor user, given site URL, username, 1120 | * password. If the user has not already had their API key generated at 1121 | * the time this method is called, the userís API key will be generated 1122 | * and returned by this method. 1123 | * 1124 | * @param $site_url The base URL of the site you use to login to 1125 | * Campaign Monitor. e.g. http://example.createsend.com/ 1126 | * @param $username The username you use to login to Campaign Monitor. 1127 | * @param $password The password you use to login to Campaign Monitor. 1128 | * @return mixed A parsed response from the server, or null if something 1129 | * failed. 1130 | * @see http://www.campaignmonitor.com/api/method/user-getapikey/ 1131 | */ 1132 | function userGetApiKey($site_url, $username, $password) 1133 | { 1134 | return $this->makeCall( 1135 | 'User.GetApiKey', 1136 | array( 1137 | 'params' => array( 1138 | 'SiteUrl' => $site_url, 1139 | 'Username' => $username, 1140 | 'Password' => $password, 1141 | ) 1142 | ) 1143 | ); 1144 | } 1145 | 1146 | /** 1147 | * A generic wrapper to feed Campaign.* calls. 1148 | * 1149 | * @param string $method The API method to call. 1150 | * @param int $campaign_id (Optional) A valid Campaign ID to check against. If not given, the default class property is used. 1151 | * @return mixed A parsed response from the server, or null if something failed. 1152 | */ 1153 | 1154 | function campaignGeneric( $method, $campaign_id = null ) 1155 | { 1156 | if ( !$campaign_id ) 1157 | $campaign_id = $this->campaign_id; 1158 | 1159 | return $this->makeCall( 'Campaign.' . $method 1160 | , array( 1161 | 'params' => array( 1162 | 'CampaignID' => $campaign_id 1163 | ) 1164 | ) 1165 | ); 1166 | } 1167 | 1168 | /** 1169 | * @param int $campaign_id (Optional) A valid Campaign ID to check against. If not given, the default class property is used. 1170 | * @return mixed A parsed response from the server, or null if something failed. 1171 | * @see http://www.campaignmonitor.com/api/Campaign.GetSummary.aspx 1172 | */ 1173 | 1174 | function campaignGetSummary( $campaign_id = null ) 1175 | { 1176 | return $this->campaignGeneric( 'GetSummary', $campaign_id ); 1177 | } 1178 | 1179 | /** 1180 | * @param int $campaign_id (Optional) A valid Campaign ID to check against. If not given, the default class property is used. 1181 | * @return mixed A parsed response from the server, or null if something failed. 1182 | * @see http://www.campaignmonitor.com/api/Campaign.GetOpens.aspx 1183 | */ 1184 | 1185 | function campaignGetOpens( $campaign_id = null ) 1186 | { 1187 | return $this->campaignGeneric( 'GetOpens', $campaign_id ); 1188 | } 1189 | 1190 | /** 1191 | * @param int $campaign_id (Optional) A valid Campaign ID to check against. If not given, the default class property is used. 1192 | * @return mixed A parsed response from the server, or null if something failed. 1193 | * @see http://www.campaignmonitor.com/api/Campaign.GetBounces.aspx 1194 | */ 1195 | 1196 | function campaignGetBounces( $campaign_id = null ) 1197 | { 1198 | return $this->campaignGeneric( 'GetBounces', $campaign_id ); 1199 | } 1200 | 1201 | /** 1202 | * @param int $campaign_id (Optional) A valid Campaign ID to check against. If not given, the default class property is used. 1203 | * @return mixed A parsed response from the server, or null if something failed. 1204 | * @see http://www.campaignmonitor.com/api/Campaign.GetSubscriberClicks.aspx 1205 | */ 1206 | 1207 | function campaignGetSubscriberClicks( $campaign_id = null ) 1208 | { 1209 | return $this->campaignGeneric( 'GetSubscriberClicks', $campaign_id ); 1210 | } 1211 | 1212 | /** 1213 | * @param int $campaign_id (Optional) A valid Campaign ID to check against. If not given, the default class property is used. 1214 | * @return mixed A parsed response from the server, or null if something failed. 1215 | * @see http://www.campaignmonitor.com/api/Campaign.GetUnsubscribes.aspx 1216 | */ 1217 | 1218 | function campaignGetUnsubscribes( $campaign_id = null ) 1219 | { 1220 | return $this->campaignGeneric( 'GetUnsubscribes', $campaign_id ); 1221 | } 1222 | 1223 | /** 1224 | * @param int $campaign_id (Optional) A valid Campaign ID to check against. If not given, the default class property is used. 1225 | * @return mixed A parsed response from the server, or null if something failed. 1226 | * @see http://www.campaignmonitor.com/api/Campaign.GetLists.aspx 1227 | */ 1228 | 1229 | function campaignGetLists( $campaign_id = null ) 1230 | { 1231 | return $this->campaignGeneric( 'GetLists', $campaign_id ); 1232 | } 1233 | 1234 | /** 1235 | * @param int $client_id The ClientID you wish to use; set it to null to use the default class property. 1236 | * @param string $name (CampaignName) Name of campaign 1237 | * @param string $subject (CampaignSubject) Subject of campaign mailing 1238 | * @param string $fromName (FromName) The From name of the sender 1239 | * @param string $fromEmail (FromEmail) The email of the sender 1240 | * @param string $replyTo (ReplyTo) An alternate email to send replies to 1241 | * @param string $htmlUrl (HtmlUrl) Location of HTML body of email 1242 | * @param string $textUrl (TextUrl) Location of plaintext body of email 1243 | * @param array $subscriberListIds (SubscriberListIDs) An array of ListIDs. This will automatically be converted to the right format 1244 | * @param array $listSegments (ListSegments) An array of segment names and their corresponding ListIDs. Each element needs to 1245 | * be an associative array with keys ListID and Name. 1246 | * @return mixed A parsed response from the server, or null if something failed. 1247 | * @see http://www.campaignmonitor.com/api/Campaign.Create.aspx 1248 | */ 1249 | 1250 | function campaignCreate( $client_id, $name, $subject, $fromName, $fromEmail, $replyTo, $htmlUrl, $textUrl, $subscriberListIds, $listSegments ) 1251 | { 1252 | if ($client_id == null) 1253 | $client_id = $this->client_id; 1254 | 1255 | $_subListIds = ''; 1256 | if ($subscriberListIds != "") { 1257 | $_subListIds = array( 'string' => array() ); 1258 | if ( is_array( $subscriberListIds ) ) { 1259 | foreach ( $subscriberListIds as $lid ) { 1260 | $_subListIds['string'][] = $lid; 1261 | } 1262 | } 1263 | } 1264 | 1265 | $_seg = ''; 1266 | if ($listSegments != "") 1267 | { 1268 | $_seg = array(); 1269 | if (is_array($listSegments)) { 1270 | for($i=0; $i < count($listSegments); $i++) { 1271 | foreach ($listSegments[$i] as $k => $v) { 1272 | $_seg['List'][$i][$k] = $v; 1273 | } 1274 | } 1275 | } 1276 | } 1277 | 1278 | return $this->makeCall( 'Campaign.Create', array( 1279 | 'params' => array( 1280 | 'ClientID' => $client_id 1281 | , 'CampaignName' => $name 1282 | , 'CampaignSubject' => $subject 1283 | , 'FromName' => $fromName 1284 | , 'FromEmail' => $fromEmail 1285 | , 'ReplyTo' => $replyTo 1286 | , 'HtmlUrl' => $htmlUrl 1287 | , 'TextUrl' => $textUrl 1288 | , 'SubscriberListIDs' => $_subListIds 1289 | , 'ListSegments' => $_seg 1290 | ) 1291 | ) 1292 | ); 1293 | } 1294 | 1295 | /** 1296 | * @param int $client_id The CampaignID you wish to use; set it to null to use the default class property 1297 | * @param string $confirmEmail (ConfirmationEmail) Email address to send confirmation of campaign send to 1298 | * @param string $sendDate (SendDate) The timestamp to send the campaign. It must be formatted as YYY-MM-DD HH:MM:SS 1299 | * and should correspond to user's timezone. 1300 | */ 1301 | 1302 | function campaignSend( $campaign_id, $confirmEmail, $sendDate ) 1303 | { 1304 | if ( $campaign_id == null ) 1305 | $campaign_id = $this->campaign_id; 1306 | 1307 | return $this->makeCall( 'Campaign.Send', array( 1308 | 'params' => array( 1309 | 'CampaignID' => $campaign_id 1310 | , 'ConfirmationEmail' => $confirmEmail 1311 | , 'SendDate' => $sendDate 1312 | ) 1313 | ) 1314 | ); 1315 | } 1316 | 1317 | /** 1318 | * Delete a campaign. 1319 | * @param $campaign_id The ID of the campaign to delete. 1320 | * @return A Status code indicating success or failure. 1321 | * @see http://www.campaignmonitor.com/api/method/campaign-delete/ 1322 | */ 1323 | function campaignDelete($campaign_id) 1324 | { 1325 | return $this->campaignGeneric('Delete', $campaign_id); 1326 | } 1327 | 1328 | /** 1329 | * @param int $client_id (ClientID) ID of the client the list will be created for 1330 | * @param string $title (Title) Name of the new list 1331 | * @param string $unsubscribePage (UnsubscribePage) URL of the page users will be 1332 | * directed to when they unsubscribe from this list. 1333 | * @param string $confirmOptIn (ConfirmOptIn) If true, the user will be sent a confirmation 1334 | * email before they are added to the list. If they click the link to confirm 1335 | * their subscription they will be added to the list. If false, they will be 1336 | * added automatically. 1337 | * @param string $confirmationSuccessPage (ConfirmationSuccessPage) URL of the page that 1338 | * users will be sent to if they confirm their subscription. Only required when 1339 | $confirmOptIn is true. 1340 | * @see http://www.campaignmonitor.com/api/method/list-create/ 1341 | */ 1342 | function listCreate( $client_id, $title, $unsubscribePage, $confirmOptIn, $confirmationSuccessPage ) 1343 | { 1344 | if ( $confirmOptIn == 'false' ) 1345 | $confirmationSuccessPage = ''; 1346 | 1347 | return $this->makeCall( 'List.Create', array( 1348 | 'params' => array( 1349 | 'ClientID' => $client_id 1350 | , 'Title' => $title 1351 | , 'UnsubscribePage' => $unsubscribePage 1352 | , 'ConfirmOptIn' => $confirmOptIn 1353 | , 'ConfirmationSuccessPage' => $confirmationSuccessPage 1354 | ) 1355 | ) 1356 | ); 1357 | } 1358 | 1359 | /** 1360 | * @param int $list_id (List) ID of the list to be updated 1361 | * @param string $title (Title) Name of the new list 1362 | * @param string $unsubscribePage (UnsubscribePage) URL of the page users will be 1363 | * directed to when they unsubscribe from this list. 1364 | * @param string $confirmOptIn (ConfirmOptIn) If true, the user will be sent a confirmation 1365 | * email before they are added to the list. If they click the link to confirm 1366 | * their subscription they will be added to the list. If false, they will be 1367 | * added automatically. 1368 | * @param string $confirmationSuccessPage (ConfirmationSuccessPage) URL of the page that 1369 | * users will be sent to if they confirm their subscription. Only required when 1370 | $confirmOptIn is true. 1371 | * @see http://www.campaignmonitor.com/api/method/list-update/ 1372 | */ 1373 | function listUpdate( $list_id, $title, $unsubscribePage, $confirmOptIn, $confirmationSuccessPage ) 1374 | { 1375 | if ( $confirmOptIn == 'false' ) 1376 | $confirmationSuccessPage = ''; 1377 | 1378 | return $this->makeCall( 'List.Update', array( 1379 | 'params' => array( 1380 | 'ListID' => $list_id 1381 | , 'Title' => $title 1382 | , 'UnsubscribePage' => $unsubscribePage 1383 | , 'ConfirmOptIn' => $confirmOptIn 1384 | , 'ConfirmationSuccessPage' => $confirmationSuccessPage 1385 | ) 1386 | ) 1387 | ); 1388 | } 1389 | 1390 | /** 1391 | * @param int $list_id (List) ID of the list to be deleted 1392 | * @see http://www.campaignmonitor.com/api/method/list-delete/ 1393 | */ 1394 | function listDelete( $list_id ) 1395 | { 1396 | return $this->makeCall( 'List.Delete', array( 1397 | 'params' => array( 1398 | 'ListID' => $list_id 1399 | ) 1400 | ) 1401 | ); 1402 | } 1403 | 1404 | /** 1405 | * @param int $list_id (List) ID of the list to be deleted 1406 | * @see http://www.campaignmonitor.com/api/method/list-getdetail/ 1407 | */ 1408 | function listGetDetail( $list_id ) 1409 | { 1410 | return $this->makeCall( 'List.GetDetail', array( 1411 | 'params' => array( 1412 | 'ListID' => $list_id 1413 | ) 1414 | ) 1415 | ); 1416 | } 1417 | 1418 | /** 1419 | * Gets statistics for a subscriber list 1420 | * @param $list_id The ID of the list whose statistics will be returned. 1421 | * @return mixed A parsed response from the server, or null if something 1422 | * @see http://www.campaignmonitor.com/api/method/list-getstats/ 1423 | */ 1424 | function listGetStats($list_id) 1425 | { 1426 | return $this->makeCall( 1427 | 'List.GetStats', 1428 | array( 1429 | 'params' => array( 1430 | 'ListID' => $list_id 1431 | ) 1432 | ) 1433 | ); 1434 | } 1435 | 1436 | /** 1437 | * @param int $list_id (ListID) A valid list ID to check against. 1438 | * @param string $fieldName (FieldName) Name of the new custom field 1439 | * @param string $dataType (DataType) Data type of the field. Options are Text, Number, 1440 | * MultiSelectOne, or MultiSelectMany 1441 | * @param string $Options (Options) The available options for a multi-valued custom field. 1442 | * Options should be separated by a double pipe ì||î. This field must be null 1443 | * for Text and Number custom fields 1444 | * @return mixed A parsed response from the server, or null if something failed. 1445 | * @see http://www.campaignmonitor.com/api/method/list-createcustomfield/ 1446 | */ 1447 | 1448 | function listCreateCustomField( $list_id, $fieldName, $dataType, $options ) 1449 | { 1450 | if ( $dataType == 'Text' || $dataType == 'Number' ) 1451 | $options = null; 1452 | 1453 | return $this->makeCall( 'List.CreateCustomField', array( 1454 | 'params' => array( 1455 | 'ListID' => $list_id 1456 | , 'FieldName' => $fieldName 1457 | , 'DataType' => $dataType 1458 | , 'Options' => $options 1459 | ) 1460 | ) 1461 | ); 1462 | } 1463 | 1464 | /** 1465 | * @param int $list_id (ListID) A valid list ID to check against. 1466 | * @return mixed A parsed response from the server, or null if something failed. 1467 | * @see http://www.campaignmonitor.com/api/method/list-getcustomfields/ 1468 | */ 1469 | 1470 | function listGetCustomFields( $list_id ) 1471 | { 1472 | return $this->makeCall( 'List.GetCustomFields', array( 1473 | 'params' => array( 1474 | 'ListID' => $list_id 1475 | ) 1476 | ) 1477 | ); 1478 | } 1479 | 1480 | /** 1481 | * @param int $list_id (ListID) A valid list ID to check against. 1482 | * @param int $key (Key) The Key of the field we want to delete. 1483 | * @return mixed A parsed response from the server, or null if something failed. 1484 | * @see http://www.campaignmonitor.com/api/method/list-deletecustomfield/ 1485 | */ 1486 | 1487 | function listDeleteCustomField( $list_id, $key ) 1488 | { 1489 | return $this->makeCall( 'List.DeleteCustomField', array( 1490 | 'params' => array( 1491 | 'ListID' => $list_id 1492 | , 'Key' => $key 1493 | ) 1494 | ) 1495 | ); 1496 | } 1497 | 1498 | /** 1499 | * @param int $client_id (ClientID) ID of the client the template will be created for 1500 | * @param string $template_name (TemplateName) Name of the new template 1501 | * @param string $html_url (HTMLPageURL) URL of the HTML page you have created for the template 1502 | * @param string $zip_url (ZipFileURL) URL of a zip file containing any other files required by the template 1503 | * @param string $screenshot_url (ScreenshotURL) URL of a screenshot of the template 1504 | * @see http://www.campaignmonitor.com/api/method/template-create/ 1505 | */ 1506 | function templateCreate($client_id, $template_name, $html_url, $zip_url, $screenshot_url) 1507 | { 1508 | return $this->makeCall('Template.Create', array( 1509 | 'params' => array( 1510 | 'ClientID' => $client_id, 1511 | 'TemplateName' => $template_name, 1512 | 'HTMLPageURL' => $html_url, 1513 | 'ZipFileURL' => $zip_url, 1514 | 'ScreenshotURL' => $screenshot_url 1515 | )) 1516 | ); 1517 | } 1518 | 1519 | /** 1520 | * @param string $template_id (TemplateID) ID of the template whose details are being requested 1521 | * @see http://www.campaignmonitor.com/api/method/template-getdetail/ 1522 | */ 1523 | function templateGetDetail($template_id) 1524 | { 1525 | return $this->makeCall('Template.GetDetail', array( 1526 | 'params' => array( 1527 | 'TemplateID' => $template_id 1528 | )) 1529 | ); 1530 | } 1531 | 1532 | /** 1533 | * @param string $template_id (TemplateID) ID of the template to be updated 1534 | * @param string $template_name (TemplateName) Name of the template 1535 | * @param string $html_url (HTMLPageURL) URL of the HTML page you have created for the template 1536 | * @param string $zip_url (ZipFileURL) URL of a zip file containing any other files required by the template 1537 | * @param string $screenshot_url (ScreenshotURL) URL of a screenshot of the template 1538 | * @see http://www.campaignmonitor.com/api/method/template-update/ 1539 | */ 1540 | function templateUpdate($template_id, $template_name, $html_url, $zip_url, $screenshot_url) 1541 | { 1542 | return $this->makeCall('Template.Update', array( 1543 | 'params' => array( 1544 | 'TemplateID' => $template_id, 1545 | 'TemplateName' => $template_name, 1546 | 'HTMLPageURL' => $html_url, 1547 | 'ZIPFileURL' => $zip_url, 1548 | 'ScreenshotURL' => $screenshot_url 1549 | )) 1550 | ); 1551 | } 1552 | 1553 | /** 1554 | * @param string $template_id (TemplateID) ID of the template to be deleted 1555 | * @see http://www.campaignmonitor.com/api/method/template-delete/ 1556 | */ 1557 | function templateDelete($template_id) 1558 | { 1559 | return $this->makeCall('Template.Delete', array( 1560 | 'params' => array( 1561 | 'TemplateID' => $template_id 1562 | )) 1563 | ); 1564 | } 1565 | } --------------------------------------------------------------------------------