├── forms ├── index.php └── settings.php ├── handlers ├── api.php ├── subscribe_widget.php ├── admin.php ├── index.php └── settings.php ├── conf ├── config.php └── embed.php ├── elefant.json ├── composer.json ├── lib ├── API.php ├── Functions.php └── MCAPI.php ├── views ├── index.html ├── subscribe_widget.html ├── admin.html └── settings.html └── README.md /forms/index.php: -------------------------------------------------------------------------------- 1 | ; -------------------------------------------------------------------------------- /handlers/api.php: -------------------------------------------------------------------------------- 1 | restful (new newsletter\API); 4 | 5 | ?> -------------------------------------------------------------------------------- /forms/settings.php: -------------------------------------------------------------------------------- 1 | ; -------------------------------------------------------------------------------- /handlers/subscribe_widget.php: -------------------------------------------------------------------------------- 1 | render ( 4 | 'newsletter/subscribe_widget', 5 | array ( 6 | 'list_id' => $data['list'], 7 | 'fwd' => $data['fwd'], 8 | 'rand' => mt_rand () 9 | ) 10 | ); 11 | 12 | ?> -------------------------------------------------------------------------------- /conf/config.php: -------------------------------------------------------------------------------- 1 | ; -------------------------------------------------------------------------------- /conf/embed.php: -------------------------------------------------------------------------------- 1 | ; -------------------------------------------------------------------------------- /elefant.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "app", 3 | "folder": "newsletter", 4 | "name": "Newsletter", 5 | "version": "0.9.0", 6 | "website": "http://www.elefantcms.com/", 7 | "repository": "git://github.com/shortjared/newsletter.git", 8 | "author": { 9 | "name": "Jared Short", 10 | "email": "jaredlshort@gmail.com" 11 | }, 12 | "requires": { 13 | "php": "5.3.2", 14 | "elefant": "1.0.1" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "elefant/app-newsletter", 3 | "type": "elefant-app", 4 | "description": "Newsletter via Mailchimp app for the Elefant CMS", 5 | "keywords": ["newsletter", "mailchimp", "subscribe", "cms", "app"], 6 | "license": "MIT", 7 | "authors": [ 8 | { 9 | "name": "Jared Short", 10 | "email": "jaredlshort@gmail.com", 11 | "homepage": "http://www.jaredshort.com/" 12 | } 13 | ], 14 | "repositories": [ 15 | {"type": "git", "url": "http://github.com/jbroadway/elefant_installer"} 16 | ], 17 | "require": { 18 | "elefant/app-installer": "*" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /lib/API.php: -------------------------------------------------------------------------------- 1 | listSubscribe ( 11 | $_POST['list_id'], 12 | $_POST['email'] 13 | ); 14 | 15 | if ($api->errorCode == 214) { 16 | return $this->error (__ ('It looks like you\'re already subscribed. Thank you!')); 17 | } elseif ($api->errorCode) { 18 | return $this->error (__ ('Unable to subscribe. Please try again later.')); 19 | } 20 | 21 | return __ ('Thank you for subscribing. Check your inbox for an email to confirm your subscription.'); 22 | } 23 | } 24 | 25 | ?> -------------------------------------------------------------------------------- /lib/Functions.php: -------------------------------------------------------------------------------- 1 | 0, 12 | 'value' => "-- Please Select List --" 13 | ); 14 | 15 | foreach ($lists as $list) { 16 | $retarr[] = (object) array ( 17 | 'key' => $list['id'], 18 | 'value' => $list['name'] 19 | ); 20 | } 21 | 22 | return $retarr; 23 | } 24 | 25 | /** 26 | * Return a raw array of list results. 27 | */ 28 | function newsletter_raw_lists ($apikey = null) { 29 | $apikey = $apikey ? $apikey : Appconf::newsletter ('Newsletter', 'mailchimp_api'); 30 | $api = new MCAPI($apikey); 31 | $retval = $api->lists (); 32 | return is_array ($retval['data']) ? $retval['data'] : array (); 33 | } 34 | 35 | ?> -------------------------------------------------------------------------------- /views/index.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |

{"Sign up to receive our email newsletter."}

4 | 5 |

6 | {"First name"}:
7 | 8 | {"Please enter your first name."} 9 |

10 | 11 |

12 | {"Last name"}:
13 | 14 | {"You must enter your last name."} 15 |

16 | 17 |

18 | {"Email address (required)"}:
19 | 20 | {"You must enter a valid email, or your email may already be registered."} 21 |

22 | 23 |

24 | 25 |
26 | -------------------------------------------------------------------------------- /handlers/admin.php: -------------------------------------------------------------------------------- 1 | require_admin (); 9 | 10 | $page->title = 'Newsletters'; 11 | $page->layout = 'admin'; 12 | 13 | if (! file_exists ('conf/app.newsletter.' . ELEFANT_ENV . '.php')) { 14 | $this->redirect ('/newsletter/settings'); 15 | } 16 | 17 | $apikey = Appconf::newsletter ('Newsletter', 'mailchimp_api'); 18 | $api = new MCAPI($apikey); 19 | 20 | $retval = $api->lists(); 21 | 22 | if ($api->errorCode) { 23 | printf ('

%s

', __ ('Unable to load lists from MailChimp at this time.')); 24 | error_log ('[newsletter/admin] ' . $api->errorCode . ' ' . $api->errorMessage); 25 | } else { 26 | echo $tpl->render ('newsletter/admin', array ( 27 | 'lists_count' => $retval['total'], 28 | 'lists' => $retval['data'], 29 | 'default_list' => Appconf::newsletter ('Newsletter', 'default_list') 30 | )); 31 | } 32 | 33 | ?> -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is an incredibly easy mailchimp integration for a newsletter subscription form/widget. 2 | 3 | ### Installation 4 | 5 | To install, unzip it into your apps folder.(Or install through git routine). 6 | 7 | Visit the link "Newsletter" in your admin tools, on the first time you will be asked for your mailchimp API key. That's it, you're done with installation. 8 | 9 | 10 | ### Using Newsletter Widget 11 | You can use it in any page, or block element. Simply click the "Newsletter : Subscription Widget" and select the mailing list you wish the individual to subscribe to. 12 | 13 | You can have as many widgets on your site, and even an single page as you want. 14 | 15 | 16 | ### Admin Page 17 | 18 | This is a quick view some of the major stats about your mailing campaigns. 19 | 20 | 21 | ### Support and Updates 22 | 23 | There is no official support or updates planned. You can seek help at http://www.elefantcms.com/forum. I will be working on this as I see fit. If you submit a pull request I will review it. 24 | 25 | 26 | -------------------------------------------------------------------------------- /views/subscribe_widget.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 |
6 | 7 | 40 | -------------------------------------------------------------------------------- /handlers/index.php: -------------------------------------------------------------------------------- 1 | id = 'newsletter'; 4 | $page->title = Appconf::newsletter ('Newsletter', 'title'); 5 | $page->layout = Appconf::newsletter ('Newsletter', 'layout'); 6 | 7 | $default_list = Appconf::newsletter ('Newsletter', 'default_list'); 8 | 9 | if (empty ($default_list)) { 10 | printf ('

%s

', __ ('The default newsletter has not yet been configured.')); 11 | return; 12 | } 13 | 14 | $form = new Form ('post', $this); 15 | 16 | echo $form->handle (function ($form) use ($default_list) { 17 | $apikey = Appconf::newsletter ('Newsletter', 'mailchimp_api'); 18 | $api = new MCAPI ($apikey); 19 | 20 | $retval = $api->listSubscribe ( 21 | $default_list, 22 | $_POST['email'], 23 | array ( 24 | 'FNAME' => $_POST['first_name'], 25 | 'LNAME' => $_POST['last_name'] 26 | ) 27 | ); 28 | 29 | if ($api->errorCode) { 30 | printf ('

%s

', __ ('Unable to load lists from MailChimp at this time.')); 31 | error_log ('[newsletter/index] ' . $api->errorCode . ' ' . $api->errorMessage); 32 | return; 33 | } 34 | 35 | $fwd = Appconf::newsletter ('Newsletter', 'forward_on_success'); 36 | if ($fwd != '') { 37 | $form->controller->redirect ($fwd); 38 | } else { 39 | printf ('

%s

', __ ('Thank you for signing up to receive our newsletter. Check your inbox for an email to confirm your subscription.')); 40 | } 41 | }); 42 | 43 | ?> -------------------------------------------------------------------------------- /views/admin.html: -------------------------------------------------------------------------------- 1 |

2 | {"Settings"} 3 |  |  4 | Visit MailChimp » 5 |

6 | 7 | {% foreach lists %} 8 |
9 |
{{ loop_value['name'] }}{% if loop_value['id'] == $data->default_list %} ({"default list"}){% end %}
10 | 11 |
12 | {{ loop_value['stats']['member_count'] }} 13 | {"Subscribers"} 14 |
15 | 16 |
17 | {{ loop_value['stats']['open_rate']|round (%s, 2) }}% 18 | {"Opens"} 19 |
20 | 21 |
22 | {{ loop_value['stats']['click_rate']|round (%s, 2) }}% 23 | {"Clicks"} 24 |
25 | 26 | 27 |
28 | {% end %} 29 | 30 | 55 | -------------------------------------------------------------------------------- /views/settings.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |

{" Where can I find my MailChimp API Key? "}

5 | 6 |

{"MailChimp API Key"}:
7 | 8 | {" You must enter your MailChimp API Key. "} 9 |

10 | 11 |

{"Newsletter page title"}:
12 | 13 | {"You must enter a page title."}

14 | 15 |

{"Redirect to thank you page (optional)"}:
16 |

17 | 18 |

{"Default newsletter"}:
19 | 24 |

25 | 26 |

{"Newsletter signup layout"}:
27 |

32 | 33 |

34 | 35 |   36 | {"Cancel"} 37 |

38 | 39 |
40 |
41 | -------------------------------------------------------------------------------- /handlers/settings.php: -------------------------------------------------------------------------------- 1 | require_admin (); 8 | 9 | require_once ('apps/admin/lib/Functions.php'); 10 | require_once ('apps/newsletter/lib/Functions.php'); 11 | 12 | $page->title = 'Newsletters - Settings'; 13 | $page->layout = 'admin'; 14 | 15 | $form = new Form ('post', $this); 16 | 17 | $form->data = array ( 18 | 'title' => Appconf::newsletter ('Newsletter', 'title'), 19 | 'mailchimp_api' => Appconf::newsletter ('Newsletter', 'mailchimp_api'), 20 | 'default_list' => Appconf::newsletter ('Newsletter', 'default_list'), 21 | 'layout' => Appconf::newsletter ('Newsletter', 'layout'), 22 | 'layouts' => admin_get_layouts (), 23 | 'forward_on_success' => Appconf::newsletter ('Newsletter', 'forward_on_success') 24 | ); 25 | 26 | echo $form->handle (function ($form) { 27 | if (empty ($_POST['default_list'])) { 28 | $lists = newsletter_raw_lists ($_POST['mailchimp_api']); 29 | if (count ($lists) > 0) { 30 | $_POST['default_list'] = $lists[0]['id']; 31 | } 32 | } 33 | 34 | $merged = Appconf::merge ('newsletter', array ( 35 | 'Newsletter' => array ( 36 | 'title' => $_POST['title'], 37 | 'mailchimp_api' => $_POST['mailchimp_api'], 38 | 'default_list' => $_POST['default_list'], 39 | 'layout' => $_POST['layout'], 40 | 'forward_on_success' => $_POST['forward_on_success'] 41 | ) 42 | )); 43 | 44 | if (! Ini::write ($merged, 'conf/app.newsletter.' . ELEFANT_ENV . '.php')) { 45 | printf ( 46 | '

%s

', 47 | __ ('Unable to save changes. Check your permissions and try again.') 48 | ); 49 | return; 50 | } 51 | 52 | $form->controller->add_notification (__ ('Settings saved.')); 53 | $form->controller->redirect ('/newsletter/admin'); 54 | }); 55 | 56 | ?> -------------------------------------------------------------------------------- /lib/MCAPI.php: -------------------------------------------------------------------------------- 1 | secure = $secure; 41 | $this->apiUrl = parse_url("http://api.mailchimp.com/" . $this->version . "/?output=php"); 42 | $this->api_key = $apikey; 43 | } 44 | function setTimeout($seconds){ 45 | if (is_int($seconds)){ 46 | $this->timeout = $seconds; 47 | return true; 48 | } 49 | } 50 | function getTimeout(){ 51 | return $this->timeout; 52 | } 53 | function useSecure($val){ 54 | if ($val===true){ 55 | $this->secure = true; 56 | } else { 57 | $this->secure = false; 58 | } 59 | } 60 | 61 | /** 62 | * Unschedule a campaign that is scheduled to be sent in the future 63 | * 64 | * @section Campaign Related 65 | * @example mcapi_campaignUnschedule.php 66 | * @example xml-rpc_campaignUnschedule.php 67 | * 68 | * @param string $cid the id of the campaign to unschedule 69 | * @return boolean true on success 70 | */ 71 | function campaignUnschedule($cid) { 72 | $params = array(); 73 | $params["cid"] = $cid; 74 | return $this->callServer("campaignUnschedule", $params); 75 | } 76 | 77 | /** 78 | * Schedule a campaign to be sent in the future 79 | * 80 | * @section Campaign Related 81 | * @example mcapi_campaignSchedule.php 82 | * @example xml-rpc_campaignSchedule.php 83 | * 84 | * @param string $cid the id of the campaign to schedule 85 | * @param string $schedule_time the time to schedule the campaign. For A/B Split "schedule" campaigns, the time for Group A - in YYYY-MM-DD HH:II:SS format in GMT 86 | * @param string $schedule_time_b optional -the time to schedule Group B of an A/B Split "schedule" campaign - in YYYY-MM-DD HH:II:SS format in GMT 87 | * @return boolean true on success 88 | */ 89 | function campaignSchedule($cid, $schedule_time, $schedule_time_b=NULL) { 90 | $params = array(); 91 | $params["cid"] = $cid; 92 | $params["schedule_time"] = $schedule_time; 93 | $params["schedule_time_b"] = $schedule_time_b; 94 | return $this->callServer("campaignSchedule", $params); 95 | } 96 | 97 | /** 98 | * Resume sending an AutoResponder or RSS campaign 99 | * 100 | * @section Campaign Related 101 | * 102 | * @param string $cid the id of the campaign to pause 103 | * @return boolean true on success 104 | */ 105 | function campaignResume($cid) { 106 | $params = array(); 107 | $params["cid"] = $cid; 108 | return $this->callServer("campaignResume", $params); 109 | } 110 | 111 | /** 112 | * Pause an AutoResponder orRSS campaign from sending 113 | * 114 | * @section Campaign Related 115 | * 116 | * @param string $cid the id of the campaign to pause 117 | * @return boolean true on success 118 | */ 119 | function campaignPause($cid) { 120 | $params = array(); 121 | $params["cid"] = $cid; 122 | return $this->callServer("campaignPause", $params); 123 | } 124 | 125 | /** 126 | * Send a given campaign immediately. For RSS campaigns, this will "start" them. 127 | * 128 | * @section Campaign Related 129 | * 130 | * @example mcapi_campaignSendNow.php 131 | * @example xml-rpc_campaignSendNow.php 132 | * 133 | * @param string $cid the id of the campaign to send 134 | * @return boolean true on success 135 | */ 136 | function campaignSendNow($cid) { 137 | $params = array(); 138 | $params["cid"] = $cid; 139 | return $this->callServer("campaignSendNow", $params); 140 | } 141 | 142 | /** 143 | * Send a test of this campaign to the provided email address 144 | * 145 | * @section Campaign Related 146 | * 147 | * @example mcapi_campaignSendTest.php 148 | * @example xml-rpc_campaignSendTest.php 149 | * 150 | * @param string $cid the id of the campaign to test 151 | * @param array $test_emails an array of email address to receive the test message 152 | * @param string $send_type optional by default (null) both formats are sent - "html" or "text" send just that format 153 | * @return boolean true on success 154 | */ 155 | function campaignSendTest($cid, $test_emails=array ( 156 | ), $send_type=NULL) { 157 | $params = array(); 158 | $params["cid"] = $cid; 159 | $params["test_emails"] = $test_emails; 160 | $params["send_type"] = $send_type; 161 | return $this->callServer("campaignSendTest", $params); 162 | } 163 | 164 | /** 165 | * Allows one to test their segmentation rules before creating a campaign using them 166 | * 167 | * @section Campaign Related 168 | * @example mcapi_campaignSegmentTest.php 169 | * @example xml-rpc_campaignSegmentTest.php 170 | * 171 | * @param string $list_id the list to test segmentation on - get lists using lists() 172 | * @param array $options with 2 keys: 173 | string "match" controls whether to use AND or OR when applying your options - expects "any" (for OR) or "all" (for AND) 174 | array "conditions" - up to 10 different criteria to apply while segmenting. Each criteria row must contain 3 keys - "field", "op", and "value" - and possibly a fourth, "extra", based on these definitions: 175 | 176 | Field = "date" : Select based on signup date 177 | Valid Op(eration): eq (is) / gt (after) / lt (before) 178 | Valid Values: 179 | string last_campaign_sent uses the date of the last campaign sent 180 | string campaign_id - uses the send date of the campaign that carriers the Id submitted - see campaigns() 181 | string YYYY-MM-DD - any date in the form of YYYY-MM-DD - note: anything that appears to start with YYYY will be treated as a date 182 | 183 | Field = "interests-X": where X is the Grouping Id from listInterestGroupings() 184 | Valid Op(erations): one / none / all 185 | Valid Values: a comma delimited of interest groups for the list - see listInterestGroupings() 186 | 187 | Field = "aim" 188 | Valid Op(erations): open / noopen / click / noclick 189 | Valid Values: "any" or a valid AIM-enabled Campaign that has been sent 190 | 191 | Field = "rating" : allows matching based on list member ratings 192 | Valid Op(erations): eq (=) / ne (!=) / gt (>) / lt (<) 193 | Valid Values: a number between 0 and 5 194 | 195 | Field = "ecomm_prod" or "ecomm_prod": allows matching product and category names from purchases 196 | Valid Op(erations): 197 | eq (=) / ne (!=) / gt (>) / lt (<) / like (like '%blah%') / nlike (not like '%blah%') / starts (like 'blah%') / ends (like '%blah') 198 | Valid Values: any string 199 | 200 | Field = "ecomm_spent_one" or "ecomm_spent_all" : allows matching purchase amounts on a single order or all orders 201 | Valid Op(erations): gt (>) / lt (<) 202 | Valid Values: a number 203 | 204 | Field = "ecomm_date" : allow matching based on order dates 205 | Valid Op(eration): eq (is) / gt (after) / lt (before) 206 | Valid Values: 207 | string YYYY-MM-DD - any date in the form of YYYY-MM-DD 208 | 209 | Field = "social_gender" : allows matching against the gender acquired from SocialPro 210 | Valid Op(eration): eq (is) / ne (is not) 211 | Valid Values: male, female 212 | 213 | Field = "social_age" : allows matching against the age acquired from SocialPro 214 | Valid Op(erations): eq (=) / ne (!=) / gt (>) / lt (<) 215 | Valid Values: any number 216 | 217 | Field = "social_influence" : allows matching against the influence acquired from SocialPro 218 | Valid Op(erations): eq (=) / ne (!=) / gt (>) / lt (<) 219 | Valid Values: a number between 0 and 5 220 | 221 | Field = "social_network" : 222 | Valid Op(erations): member (is a member of) / notmember (is not a member of) 223 | Valid Values: twitter, facebook, myspace, linkedin, flickr 224 | 225 | Field = "static_segment" : 226 | Valid Op(eration): eq (is in) / ne (is not in) 227 | Valid Values: an int - get from listStaticSegments() 228 | 229 | Field = An Address Merge Var. Use Merge0-Merge30 or the Custom Tag you've setup for your merge field - see listMergeVars(). Note, Address fields can still be used with the default operations below - this section is broken out solely to highlight the differences in using the geolocation routines. 230 | Valid Op(erations): geoin 231 | Valid Values: The number of miles an address should be within 232 | Extra Value: The Zip Code to be used as the center point 233 | 234 | Default Field = A Merge Var. Use Merge0-Merge30 or the Custom Tag you've setup for your merge field - see listMergeVars() 235 | Valid Op(erations): 236 | eq (=) / ne (!=) / gt (>) / lt (<) / like (like '%blah%') / nlike (not like '%blah%') / starts (like 'blah%') / ends (like '%blah') 237 | Valid Values: any string 238 | * @return int total The total number of subscribers matching your segmentation options 239 | */ 240 | function campaignSegmentTest($list_id, $options) { 241 | $params = array(); 242 | $params["list_id"] = $list_id; 243 | $params["options"] = $options; 244 | return $this->callServer("campaignSegmentTest", $params); 245 | } 246 | 247 | /** 248 | * Create a new draft campaign to send. You can not have more than 32,000 campaigns in your account. 249 | * 250 | * @section Campaign Related 251 | * @example mcapi_campaignCreate.php 252 | * @example xml-rpc_campaignCreate.php 253 | * @example xml-rpc_campaignCreateABSplit.php 254 | * @example xml-rpc_campaignCreateRss.php 255 | * 256 | * @param string $type the Campaign Type to create - one of "regular", "plaintext", "absplit", "rss", "trans", "auto" 257 | * @param array $options a hash of the standard options for this campaign : 258 | string list_id the list to send this campaign to- get lists using lists() 259 | string subject the subject line for your campaign message 260 | string from_email the From: email address for your campaign message 261 | string from_name the From: name for your campaign message (not an email address) 262 | string to_name the To: name recipients will see (not email address) 263 | int template_id optional - use this user-created template to generate the HTML content of the campaign (takes precendence over other template options) 264 | int gallery_template_id optional - use a template from the public gallery to generate the HTML content of the campaign (takes precendence over base template options) 265 | int base_template_id optional - use this a base/start-from-scratch template to generate the HTML content of the campaign 266 | int folder_id optional - automatically file the new campaign in the folder_id passed. Get using folders() - note that Campaigns and Autoresponders have separate folder setupsn 267 | array tracking optional - set which recipient actions will be tracked, as a struct of boolean values with the following keys: "opens", "html_clicks", and "text_clicks". By default, opens and HTML clicks will be tracked. Click tracking can not be disabled for Free accounts. 268 | string title optional - an internal name to use for this campaign. By default, the campaign subject will be used. 269 | boolean authenticate optional - set to true to enable SenderID, DomainKeys, and DKIM authentication, defaults to false. 270 | array analytics optional - if provided, use a struct with "service type" as a key and the "service tag" as a value. For Google, this should be "google"=>"your_google_analytics_key_here". Note that only "google" is currently supported - a Google Analytics tags will be added to all links in the campaign with this string attached. Others may be added in the future 271 | boolean auto_footer optional Whether or not we should auto-generate the footer for your content. Mostly useful for content from URLs or Imports 272 | boolean inline_css optional Whether or not css should be automatically inlined when this campaign is sent, defaults to false. 273 | boolean generate_text optional Whether of not to auto-generate your Text content from the HTML content. Note that this will be ignored if the Text part of the content passed is not empty, defaults to false. 274 | boolean auto_tweet optional If set, this campaign will be auto-tweeted when it is sent - defaults to false. Note that if a Twitter account isn't linked, this will be silently ignored. 275 | boolean timewarp optional If set, this campaign must be scheduled 24 hours in advance of sending - default to false. Only valid for "regular" campaigns and "absplit" campaigns that split on schedule_time. 276 | boolean ecomm360 optional If set, our Ecommerce360 tracking will be enabled for links in the campaign 277 | 278 | * @param array $content the content for this campaign - use a struct with the following keys: 279 | string html for pasted HTML content 280 | string text for the plain-text version 281 | string url to have us pull in content from a URL. Note, this will override any other content options - for lists with Email Format options, you'll need to turn on generate_text as well 282 | string archive to send a Base64 encoded archive file for us to import all media from. Note, this will override any other content options - for lists with Email Format options, you'll need to turn on generate_text as well 283 | string archive_type optional - only necessary for the "archive" option. Supported formats are: zip, tar.gz, tar.bz2, tar, tgz, tbz . If not included, we will default to zip 284 | 285 | If you chose a template instead of pasting in your HTML content, then use "html_" followed by the template sections as keys - for example, use a key of "html_MAIN" to fill in the "MAIN" section of a template. Supported template sections include: "html_HEADER", "html_MAIN", "html_SIDECOLUMN", and "html_FOOTER" 286 | * @param array $segment_opts optional - if you wish to do Segmentation with this campaign this array should contain: see campaignSegmentTest(). It's suggested that you test your options against campaignSegmentTest(). Also, "trans" campaigns do not support segmentation. 287 | * @param array $type_opts optional - 288 | For RSS Campaigns this, array should contain: 289 | string url the URL to pull RSS content from - it will be verified and must exist 290 | string schedule optional one of "daily", "weekly", "monthly" - defaults to "daily" 291 | string schedule_hour optional an hour between 0 and 24 - default to 4 (4am local time) - applies to all schedule types 292 | string schedule_weekday optional for "weekly" only, a number specifying the day of the week to send: 0 (Sunday) - 6 (Saturday) - defaults to 1 (Monday) 293 | string schedule_monthday optional for "monthly" only, a number specifying the day of the month to send (1 - 28) or "last" for the last day of a given month. Defaults to the 1st day of the month 294 | 295 | For A/B Split campaigns, this array should contain: 296 | string split_test The values to segment based on. Currently, one of: "subject", "from_name", "schedule". NOTE, for "schedule", you will need to call campaignSchedule() separately! 297 | string pick_winner How the winner will be picked, one of: "opens" (by the open_rate), "clicks" (by the click rate), "manual" (you pick manually) 298 | int wait_units optional the default time unit to wait before auto-selecting a winner - use "3600" for hours, "86400" for days. Defaults to 86400. 299 | int wait_time optional the number of units to wait before auto-selecting a winner - defaults to 1, so if not set, a winner will be selected after 1 Day. 300 | int split_size optional this is a percentage of what size the Campaign's List plus any segmentation options results in. "schedule" type forces 50%, all others default to 10% 301 | string from_name_a optional sort of, required when split_test is "from_name" 302 | string from_name_b optional sort of, required when split_test is "from_name" 303 | string from_email_a optional sort of, required when split_test is "from_name" 304 | string from_email_b optional sort of, required when split_test is "from_name" 305 | string subject_a optional sort of, required when split_test is "subject" 306 | string subject_b optional sort of, required when split_test is "subject" 307 | 308 | For AutoResponder campaigns, this array should contain: 309 | string offset-units one of "day", "week", "month", "year" - required 310 | string offset-time optional, sort of - the number of units must be a number greater than 0 for signup based autoresponders 311 | string offset-dir either "before" or "after" 312 | string event optional "signup" (default) to base this on double-optin signup, "date" or "annual" to base this on merge field in the list 313 | string event-datemerge optional sort of, this is required if the event is "date" or "annual" 314 | 315 | * 316 | * @return string the ID for the created campaign 317 | */ 318 | function campaignCreate($type, $options, $content, $segment_opts=NULL, $type_opts=NULL) { 319 | $params = array(); 320 | $params["type"] = $type; 321 | $params["options"] = $options; 322 | $params["content"] = $content; 323 | $params["segment_opts"] = $segment_opts; 324 | $params["type_opts"] = $type_opts; 325 | return $this->callServer("campaignCreate", $params); 326 | } 327 | 328 | /** Update just about any setting for a campaign that has not been sent. See campaignCreate() for details. 329 | * 330 | * 331 | * Caveats:
335 | * @section Campaign Related 336 | * 337 | * @example mcapi_campaignUpdate.php 338 | * @example mcapi_campaignUpdateAB.php 339 | * @example xml-rpc_campaignUpdate.php 340 | * @example xml-rpc_campaignUpdateAB.php 341 | * 342 | * @param string $cid the Campaign Id to update 343 | * @param string $name the parameter name ( see campaignCreate() ). For items in the options array, this will be that parameter's name (subject, from_email, etc.). Additional parameters will be that option name (content, segment_opts). "type_opts" will be the name of the type - rss, auto, trans, etc. 344 | * @param mixed $value an appropriate value for the parameter ( see campaignCreate() ). For items in the options array, this will be that parameter's value. For additional parameters, this is the same value passed to them. 345 | * @return boolean true if the update succeeds, otherwise an error will be thrown 346 | */ 347 | function campaignUpdate($cid, $name, $value) { 348 | $params = array(); 349 | $params["cid"] = $cid; 350 | $params["name"] = $name; 351 | $params["value"] = $value; 352 | return $this->callServer("campaignUpdate", $params); 353 | } 354 | 355 | /** Replicate a campaign. 356 | * 357 | * @section Campaign Related 358 | * 359 | * @example mcapi_campaignReplicate.php 360 | * 361 | * @param string $cid the Campaign Id to replicate 362 | * @return string the id of the replicated Campaign created, otherwise an error will be thrown 363 | */ 364 | function campaignReplicate($cid) { 365 | $params = array(); 366 | $params["cid"] = $cid; 367 | return $this->callServer("campaignReplicate", $params); 368 | } 369 | 370 | /** Delete a campaign. Seriously, "poof, gone!" - be careful! 371 | * 372 | * @section Campaign Related 373 | * 374 | * @example mcapi_campaignDelete.php 375 | * 376 | * @param string $cid the Campaign Id to delete 377 | * @return boolean true if the delete succeeds, otherwise an error will be thrown 378 | */ 379 | function campaignDelete($cid) { 380 | $params = array(); 381 | $params["cid"] = $cid; 382 | return $this->callServer("campaignDelete", $params); 383 | } 384 | 385 | /** 386 | * Get the list of campaigns and their details matching the specified filters 387 | * 388 | * @section Campaign Related 389 | * @example mcapi_campaigns.php 390 | * @example xml-rpc_campaigns.php 391 | * 392 | * @param array $filters a hash of filters to apply to this query - all are optional: 393 | string campaign_id optional - return a single campaign using a know campaign_id 394 | string list_id optional - the list to send this campaign to- get lists using lists(). Accepts multiples separated by commas when not using exact matching. 395 | int folder_id optional - only show campaigns from this folder id - get folders using campaignFolders(). Accepts multiples separated by commas when not using exact matching. 396 | int template_id optional - only show campaigns using this template id - get templates using templates(). Accepts multiples separated by commas when not using exact matching. 397 | string status optional - return campaigns of a specific status - one of "sent", "save", "paused", "schedule", "sending". Accepts multiples separated by commas when not using exact matching. 398 | string type optional - return campaigns of a specific type - one of "regular", "plaintext", "absplit", "rss", "trans", "auto". Accepts multiples separated by commas when not using exact matching. 399 | string from_name optional - only show campaigns that have this "From Name" 400 | string from_email optional - only show campaigns that have this "Reply-to Email" 401 | string title optional - only show campaigns that have this title 402 | string subject optional - only show campaigns that have this subject 403 | string sendtime_start optional - only show campaigns that have been sent since this date/time (in GMT) - format is YYYY-MM-DD HH:mm:ss (24hr) 404 | string sendtime_end optional - only show campaigns that have been sent before this date/time (in GMT) - format is YYYY-MM-DD HH:mm:ss (24hr) 405 | boolean exact optional - flag for whether to filter on exact values when filtering, or search within content for filter values - defaults to true. Using this disables the use of any filters that accept multiples. 406 | * @param int $start optional - control paging of campaigns, start results at this campaign #, defaults to 1st page of data (page 0) 407 | * @param int $limit optional - control paging of campaigns, number of campaigns to return with each call, defaults to 25 (max=1000) 408 | * @return array an array containing a count of all matching campaigns and the specific ones for the current page (see Returned Fields for description) 409 | * @returnf int total the total number of campaigns matching the filters passed in 410 | * @returnf array data the data for each campaign being returned 411 | string id Campaign Id (used for all other campaign functions) 412 | int web_id The Campaign id used in our web app, allows you to create a link directly to it 413 | string list_id The List used for this campaign 414 | int folder_id The Folder this campaign is in 415 | int template_id The Template this campaign uses 416 | string content_type How the campaign's content is put together - one of 'template', 'html', 'url' 417 | string title Title of the campaign 418 | string type The type of campaign this is (regular,plaintext,absplit,rss,inspection,trans,auto) 419 | string create_time Creation time for the campaign 420 | string send_time Send time for the campaign - also the scheduled time for scheduled campaigns. 421 | int emails_sent Number of emails email was sent to 422 | string status Status of the given campaign (save,paused,schedule,sending,sent) 423 | string from_name From name of the given campaign 424 | string from_email Reply-to email of the given campaign 425 | string subject Subject of the given campaign 426 | string to_name Custom "To:" email string using merge variables 427 | string archive_url Archive link for the given campaign 428 | boolean inline_css Whether or not the campaign content's css was auto-inlined 429 | string analytics Either "google" if enabled or "N" if disabled 430 | string analytics_tag The name/tag the campaign's links were tagged with if analytics were enabled. 431 | boolean authenticate Whether or not the campaign was authenticated 432 | boolean ecomm360 Whether or not ecomm360 tracking was appended to links 433 | boolean auto_tweet Whether or not the campaign was auto tweeted after sending 434 | string auto_fb_post A comma delimited list of Facebook Profile/Page Ids the campaign was posted to after sending. If not used, blank. 435 | boolean auto_footer Whether or not the auto_footer was manually turned on 436 | boolean timewarp Whether or not the campaign used Timewarp 437 | boolean timewarp_schedule The time, in GMT, that the Timewarp campaign is being sent. For A/B Split campaigns, this is blank and is instead in their schedule_a and schedule_b in the type_opts array 438 | array tracking containing "text_clicks", "html_clicks", and "opens" as boolean values representing whether or not they were enabled 439 | string segment_text a string marked-up with HTML explaining the segment used for the campaign in plain English 440 | array segment_opts the segment used for the campaign - can be passed to campaignSegmentTest() or campaignCreate() 441 | array type_opts the type-specific options for the campaign - can be passed to campaignCreate() 442 | */ 443 | function campaigns($filters=array ( 444 | ), $start=0, $limit=25) { 445 | $params = array(); 446 | $params["filters"] = $filters; 447 | $params["start"] = $start; 448 | $params["limit"] = $limit; 449 | return $this->callServer("campaigns", $params); 450 | } 451 | 452 | /** 453 | * Given a list and a campaign, get all the relevant campaign statistics (opens, bounces, clicks, etc.) 454 | * 455 | * @section Campaign Stats 456 | * 457 | * @example mcapi_campaignStats.php 458 | * @example xml-rpc_campaignStats.php 459 | * 460 | * @param string $cid the campaign id to pull stats for (can be gathered using campaigns()) 461 | * @return array struct of the statistics for this campaign 462 | * @returnf int syntax_errors Number of email addresses in campaign that had syntactical errors. 463 | * @returnf int hard_bounces Number of email addresses in campaign that hard bounced. 464 | * @returnf int soft_bounces Number of email addresses in campaign that soft bounced. 465 | * @returnf int unsubscribes Number of email addresses in campaign that unsubscribed. 466 | * @returnf int abuse_reports Number of email addresses in campaign that reported campaign for abuse. 467 | * @returnf int forwards Number of times email was forwarded to a friend. 468 | * @returnf int forwards_opens Number of times a forwarded email was opened. 469 | * @returnf int opens Number of times the campaign was opened. 470 | * @returnf date last_open Date of the last time the email was opened. 471 | * @returnf int unique_opens Number of people who opened the campaign. 472 | * @returnf int clicks Number of times a link in the campaign was clicked. 473 | * @returnf int unique_clicks Number of unique recipient/click pairs for the campaign. 474 | * @returnf date last_click Date of the last time a link in the email was clicked. 475 | * @returnf int users_who_clicked Number of unique recipients who clicked on a link in the campaign. 476 | * @returnf int emails_sent Number of email addresses campaign was sent to. 477 | * @returnf array absplit If this was an absplit campaign, stats for the A and B groups will be returned 478 | int bounces_a bounces for the A group 479 | int bounces_b bounces for the B group 480 | int forwards_a forwards for the A group 481 | int forwards_b forwards for the B group 482 | int abuse_reports_a abuse reports for the A group 483 | int abuse_reports_b abuse reports for the B group 484 | int unsubs_a unsubs for the A group 485 | int unsubs_b unsubs for the B group 486 | int recipients_click_a clicks for the A group 487 | int recipients_click_b clicks for the B group 488 | int forwards_opens_a opened forwards for the A group 489 | int forwards_opens_b opened forwards for the A group 490 | * @returnf array timewarp If this campaign was a Timewarp campaign, an array of stats from each timezone for it, with the GMT offset as they key. Each timezone will contain: 491 | int opens opens for this timezone 492 | string last_open the date/time of the last open for this timezone 493 | int unique_opens the unique opens for this timezone 494 | int clicks the total clicks for this timezone 495 | string last_click the date/time of the last click for this timezone 496 | int unique_opens the unique clicks for this timezone 497 | int bounces the total bounces for this timezone 498 | int total the total number of members sent to in this timezone 499 | int sent the total number of members delivered to in this timezone 500 | */ 501 | function campaignStats($cid) { 502 | $params = array(); 503 | $params["cid"] = $cid; 504 | return $this->callServer("campaignStats", $params); 505 | } 506 | 507 | /** 508 | * Get an array of the urls being tracked, and their click counts for a given campaign 509 | * 510 | * @section Campaign Stats 511 | * 512 | * @example mcapi_campaignClickStats.php 513 | * @example xml-rpc_campaignClickStats.php 514 | * 515 | * @param string $cid the campaign id to pull stats for (can be gathered using campaigns()) 516 | * @return struct urls will be keys and contain their associated statistics: 517 | * @returnf int clicks Number of times the specific link was clicked 518 | * @returnf int unique Number of unique people who clicked on the specific link 519 | */ 520 | function campaignClickStats($cid) { 521 | $params = array(); 522 | $params["cid"] = $cid; 523 | return $this->callServer("campaignClickStats", $params); 524 | } 525 | 526 | /** 527 | * Get the top 5 performing email domains for this campaign. Users want more than 5 should use campaign campaignEmailStatsAIM() 528 | * or campaignEmailStatsAIMAll() and generate any additional stats they require. 529 | * 530 | * @section Campaign Stats 531 | * 532 | * @example mcapi_campaignEmailDomainPerformance.php 533 | * 534 | * @param string $cid the campaign id to pull email domain performance for (can be gathered using campaigns()) 535 | * @return array domains email domains and their associated stats 536 | * @returnf string domain Domain name or special "Other" to roll-up stats past 5 domains 537 | * @returnf int total_sent Total Email across all domains - this will be the same in every row 538 | * @returnf int emails Number of emails sent to this domain 539 | * @returnf int bounces Number of bounces 540 | * @returnf int opens Number of opens 541 | * @returnf int clicks Number of clicks 542 | * @returnf int unsubs Number of unsubs 543 | * @returnf int delivered Number of deliveries 544 | * @returnf int emails_pct Percentage of emails that went to this domain (whole number) 545 | * @returnf int bounces_pct Percentage of bounces from this domain (whole number) 546 | * @returnf int opens_pct Percentage of opens from this domain (whole number) 547 | * @returnf int clicks_pct Percentage of clicks from this domain (whole number) 548 | * @returnf int unsubs_pct Percentage of unsubs from this domain (whole number) 549 | */ 550 | function campaignEmailDomainPerformance($cid) { 551 | $params = array(); 552 | $params["cid"] = $cid; 553 | return $this->callServer("campaignEmailDomainPerformance", $params); 554 | } 555 | 556 | /** 557 | * Get all email addresses the campaign was successfully sent to (ie, no bounces) 558 | * 559 | * @section Campaign Stats 560 | * 561 | * @param string $cid the campaign id to pull members for (can be gathered using campaigns()) 562 | * @param string $status optional the status to pull - one of 'sent', 'hard' (bounce), or 'soft' (bounce). By default, all records are returned 563 | * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0) 564 | * @param int $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000 565 | * @return array a total of all matching emails and the specific emails for this page 566 | * @returnf int total the total number of members for the campaign and status 567 | * @returnf array data the full campaign member records 568 | string email the email address sent to 569 | string status the status of the send - one of 'sent', 'hard', 'soft' 570 | string absplit_group if this was an absplit campaign, one of 'a','b', or 'winner' 571 | string tz_group if this was an timewarp campaign the timezone GMT offset the member was included in 572 | */ 573 | function campaignMembers($cid, $status=NULL, $start=0, $limit=1000) { 574 | $params = array(); 575 | $params["cid"] = $cid; 576 | $params["status"] = $status; 577 | $params["start"] = $start; 578 | $params["limit"] = $limit; 579 | return $this->callServer("campaignMembers", $params); 580 | } 581 | 582 | /** 583 | * DEPRECATED Get all email addresses with Hard Bounces for a given campaign 584 | * 585 | * @deprecated See campaignMembers() for a replacement 586 | * 587 | * @section Campaign Stats 588 | * 589 | * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns()) 590 | * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0) 591 | * @param int $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000 592 | * @return array a total of all hard bounced emails and the specific emails for this page 593 | * @returnf int total the total number of hard bounces for the campaign 594 | * @returnf array data the full email addresses that bounced 595 | string email the email address that bounced 596 | */ 597 | function campaignHardBounces($cid, $start=0, $limit=1000) { 598 | $params = array(); 599 | $params["cid"] = $cid; 600 | $params["start"] = $start; 601 | $params["limit"] = $limit; 602 | return $this->callServer("campaignHardBounces", $params); 603 | } 604 | 605 | /** 606 | * DEPRECATED Get all email addresses with Soft Bounces for a given campaign 607 | * 608 | * @deprecated See campaignMembers() for a replacement 609 | * 610 | * @section Campaign Stats 611 | * 612 | * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns()) 613 | * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0) 614 | * @param int $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000 615 | * @return array a total of all soft bounced emails and the specific emails for this page 616 | * @returnf int total the total number of soft bounces for the campaign 617 | * @returnf array data the full email addresses that bounced 618 | string email the email address that bounced 619 | */ 620 | function campaignSoftBounces($cid, $start=0, $limit=1000) { 621 | $params = array(); 622 | $params["cid"] = $cid; 623 | $params["start"] = $start; 624 | $params["limit"] = $limit; 625 | return $this->callServer("campaignSoftBounces", $params); 626 | } 627 | 628 | /** 629 | * Get all unsubscribed email addresses for a given campaign 630 | * 631 | * @section Campaign Stats 632 | * 633 | * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns()) 634 | * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0) 635 | * @param int $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000 636 | * @return array email addresses that unsubscribed from this campaign along with reasons, if given 637 | * @return array a total of all unsubscribed emails and the specific emails for this page 638 | * @returnf int total the total number of unsubscribes for the campaign 639 | * @returnf array data the full email addresses that unsubscribed 640 | string email the email address that unsubscribed 641 | string reason For unsubscribes only - the reason collected for the unsubscribe. If populated, one of 'NORMAL','NOSIGNUP','INAPPROPRIATE','SPAM','OTHER' 642 | string reason_text For unsubscribes only - if the reason is OTHER, the text entered. 643 | */ 644 | function campaignUnsubscribes($cid, $start=0, $limit=1000) { 645 | $params = array(); 646 | $params["cid"] = $cid; 647 | $params["start"] = $start; 648 | $params["limit"] = $limit; 649 | return $this->callServer("campaignUnsubscribes", $params); 650 | } 651 | 652 | /** 653 | * Get all email addresses that complained about a given campaign 654 | * 655 | * @section Campaign Stats 656 | * 657 | * @example mcapi_campaignAbuseReports.php 658 | * 659 | * @param string $cid the campaign id to pull abuse reports for (can be gathered using campaigns()) 660 | * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0) 661 | * @param int $limit optional for large data sets, the number of results to return - defaults to 500, upper limit set at 1000 662 | * @param string $since optional pull only messages since this time - use YYYY-MM-DD HH:II:SS format in GMT 663 | * @return array reports the abuse reports for this campaign 664 | * @returnf string date date/time the abuse report was received and processed 665 | * @returnf string email the email address that reported abuse 666 | * @returnf string type an internal type generally specifying the orginating mail provider - may not be useful outside of filling report views 667 | */ 668 | function campaignAbuseReports($cid, $since=NULL, $start=0, $limit=500) { 669 | $params = array(); 670 | $params["cid"] = $cid; 671 | $params["since"] = $since; 672 | $params["start"] = $start; 673 | $params["limit"] = $limit; 674 | return $this->callServer("campaignAbuseReports", $params); 675 | } 676 | 677 | /** 678 | * Retrieve the text presented in our app for how a campaign performed and any advice we may have for you - best 679 | * suited for display in customized reports pages. Note: some messages will contain HTML - clean tags as necessary 680 | * 681 | * @section Campaign Stats 682 | * 683 | * @example mcapi_campaignAdvice.php 684 | * 685 | * @param string $cid the campaign id to pull advice text for (can be gathered using campaigns()) 686 | * @return array advice on the campaign's performance 687 | * @returnf msg the advice message 688 | * @returnf type the "type" of the message. one of: negative, positive, or neutral 689 | */ 690 | function campaignAdvice($cid) { 691 | $params = array(); 692 | $params["cid"] = $cid; 693 | return $this->callServer("campaignAdvice", $params); 694 | } 695 | 696 | /** 697 | * Retrieve the Google Analytics data we've collected for this campaign. Note, requires Google Analytics Add-on to be installed and configured. 698 | * 699 | * @section Campaign Stats 700 | * 701 | * @example mcapi_campaignAnalytics.php 702 | * 703 | * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns()) 704 | * @return array analytics we've collected for the passed campaign. 705 | * @returnf int visits number of visits 706 | * @returnf int pages number of page views 707 | * @returnf int new_visits new visits recorded 708 | * @returnf int bounces vistors who "bounced" from your site 709 | * @returnf double time_on_site the total time visitors spent on your sites 710 | * @returnf int goal_conversions number of goals converted 711 | * @returnf double goal_value value of conversion in dollars 712 | * @returnf double revenue revenue generated by campaign 713 | * @returnf int transactions number of transactions tracked 714 | * @returnf int ecomm_conversions number Ecommerce transactions tracked 715 | * @returnf array goals an array containing goal names and number of conversions 716 | */ 717 | function campaignAnalytics($cid) { 718 | $params = array(); 719 | $params["cid"] = $cid; 720 | return $this->callServer("campaignAnalytics", $params); 721 | } 722 | 723 | /** 724 | * Retrieve the countries and number of opens tracked for each. Email address are not returned. 725 | * 726 | * @section Campaign Stats 727 | * 728 | * 729 | * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns()) 730 | * @return array countries an array of countries where opens occurred 731 | * @returnf string code The ISO3166 2 digit country code 732 | * @returnf string name A version of the country name, if we have it 733 | * @returnf int opens The total number of opens that occurred in the country 734 | * @returnf bool region_detail Whether or not a subsequent call to campaignGeoOpensByCountry() will return anything 735 | */ 736 | function campaignGeoOpens($cid) { 737 | $params = array(); 738 | $params["cid"] = $cid; 739 | return $this->callServer("campaignGeoOpens", $params); 740 | } 741 | 742 | /** 743 | * Retrieve the regions and number of opens tracked for a certain country. Email address are not returned. 744 | * 745 | * @section Campaign Stats 746 | * 747 | * 748 | * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns()) 749 | * @param string $code An ISO3166 2 digit country code 750 | * @return array regions an array of regions within the provided country where opens occurred. 751 | * @returnf string code An internal code for the region. When this is blank, it indicates we know the country, but not the region 752 | * @returnf string name The name of the region, if we have one. For blank "code" values, this will be "Rest of Country" 753 | * @returnf int opens The total number of opens that occurred in the country 754 | */ 755 | function campaignGeoOpensForCountry($cid, $code) { 756 | $params = array(); 757 | $params["cid"] = $cid; 758 | $params["code"] = $code; 759 | return $this->callServer("campaignGeoOpensForCountry", $params); 760 | } 761 | 762 | /** 763 | * Retrieve the tracked eepurl mentions on Twitter 764 | * 765 | * @section Campaign Stats 766 | * 767 | * 768 | * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns()) 769 | * @return array stats an array containing tweets, retweets, clicks, and referrer related to using the campaign's eepurl 770 | * @returnf array twitter various Twitter related stats 771 | int tweets Total number of tweets seen 772 | string first_tweet date and time of the first tweet seen 773 | string last_tweet date and time of the last tweet seen 774 | int retweets Total number of retweets seen 775 | string first_retweet date and time of the first retweet seen 776 | string last_retweet date and time of the last retweet seen 777 | array statuses an array of statuses recorded inclduing the status, screen_name, status_id, and datetime fields plus an is_retweet flag 778 | * @returnf array clicks stats related to click-throughs on the eepurl 779 | int clicks Total number of clicks seen 780 | string first_click date and time of the first click seen 781 | string last_click date and time of the first click seen 782 | array locations an array of geographic locations including country, region, and total clicks 783 | * @returnf array referrers an array of arrays, each containing 784 | string referrer the referrer, truncated to 100 bytes 785 | int clicks Total number of clicks seen from this referrer 786 | string first_click date and time of the first click seen from this referrer 787 | string last_click date and time of the first click seen from this referrer 788 | */ 789 | function campaignEepUrlStats($cid) { 790 | $params = array(); 791 | $params["cid"] = $cid; 792 | return $this->callServer("campaignEepUrlStats", $params); 793 | } 794 | 795 | /** 796 | * Retrieve the most recent full bounce message for a specific email address on the given campaign. 797 | * Messages over 30 days old are subject to being removed 798 | * 799 | * 800 | * @section Campaign Stats 801 | * 802 | * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns()) 803 | * @param string $email the email address or unique id of the member to pull a bounce message for. 804 | * @return array the full bounce message for this email+campaign along with some extra data. 805 | * @returnf string date date/time the bounce was received and processed 806 | * @returnf string email the email address that bounced 807 | * @returnf string message the entire bounce message received 808 | */ 809 | function campaignBounceMessage($cid, $email) { 810 | $params = array(); 811 | $params["cid"] = $cid; 812 | $params["email"] = $email; 813 | return $this->callServer("campaignBounceMessage", $params); 814 | } 815 | 816 | /** 817 | * Retrieve the full bounce messages for the given campaign. Note that this can return very large amounts 818 | * of data depending on how large the campaign was and how much cruft the bounce provider returned. Also, 819 | * message over 30 days old are subject to being removed 820 | * 821 | * @section Campaign Stats 822 | * 823 | * @example mcapi_campaignBounceMessages.php 824 | * 825 | * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns()) 826 | * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0) 827 | * @param int $limit optional for large data sets, the number of results to return - defaults to 25, upper limit set at 50 828 | * @param string $since optional pull only messages since this time - use YYYY-MM-DD format in GMT (we only store the date, not the time) 829 | * @return array bounces the full bounce messages for this campaign 830 | * @returnf int total that total number of bounce messages for the campaign 831 | * @returnf array data an array containing the data for this page 832 | string date date/time the bounce was received and processed 833 | string email the email address that bounced 834 | string message the entire bounce message received 835 | */ 836 | function campaignBounceMessages($cid, $start=0, $limit=25, $since=NULL) { 837 | $params = array(); 838 | $params["cid"] = $cid; 839 | $params["start"] = $start; 840 | $params["limit"] = $limit; 841 | $params["since"] = $since; 842 | return $this->callServer("campaignBounceMessages", $params); 843 | } 844 | 845 | /** 846 | * Retrieve the Ecommerce Orders tracked by campaignEcommOrderAdd() 847 | * 848 | * @section Campaign Stats 849 | * 850 | * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns()) 851 | * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0) 852 | * @param int $limit optional for large data sets, the number of results to return - defaults to 100, upper limit set at 500 853 | * @param string $since optional pull only messages since this time - use YYYY-MM-DD HH:II:SS format in GMT 854 | * @return array the total matching orders and the specific orders for the requested page 855 | * @returnf int total the total matching orders 856 | * @returnf array data the actual data for each order being returned 857 | string store_id the store id generated by the plugin used to uniquely identify a store 858 | string store_name the store name collected by the plugin - often the domain name 859 | string order_id the internal order id the store tracked this order by 860 | string email the email address that received this campaign and is associated with this order 861 | double order_total the order total 862 | double tax_total the total tax for the order (if collected) 863 | double ship_total the shipping total for the order (if collected) 864 | string order_date the date the order was tracked - from the store if possible, otherwise the GMT time we recieved it 865 | array lines containing detail of the order - product, category, quantity, item cost 866 | */ 867 | function campaignEcommOrders($cid, $start=0, $limit=100, $since=NULL) { 868 | $params = array(); 869 | $params["cid"] = $cid; 870 | $params["start"] = $start; 871 | $params["limit"] = $limit; 872 | $params["since"] = $since; 873 | return $this->callServer("campaignEcommOrders", $params); 874 | } 875 | 876 | /** 877 | * Get the URL to a customized VIP Report for the specified campaign and optionally send an email to someone with links to it. Note subsequent calls will overwrite anything already set for the same campign (eg, the password) 878 | * 879 | * @section Campaign Related 880 | * 881 | * @param string $cid the campaign id to share a report for (can be gathered using campaigns()) 882 | * @param array $opts optional various parameters which can be used to configure the shared report 883 | string header_type optional - "text" or "image', defaults to "text' 884 | string header_data optional - if "header_type" is text, the text to display. if "header_type" is "image" a valid URL to an image file. Note that images will be resized to be no more than 500x150. Defaults to the Accounts Company Name. 885 | boolean secure optional - whether to require a password for the shared report. defaults to "true" 886 | string password optional - if secure is true and a password is not included, we will generate one. It is always returned. 887 | string to_email optional - optional, email address to share the report with - no value means an email will not be sent 888 | array theme optional - an array containing either 3 or 6 character color code values for: "bg_color", "header_color", "current_tab", "current_tab_text", "normal_tab", "normal_tab_text", "hover_tab", "hover_tab_text" 889 | string css_url optional - a link to an external CSS file to be included after our default CSS (http://vip-reports.net/css/vip.css) only if loaded via the "secure_url" - max 255 bytes 890 | * @return struct Struct containing details for the shared report 891 | * @returnf string title The Title of the Campaign being shared 892 | * @returnf string url The URL to the shared report 893 | * @returnf string secure_url The URL to the shared report, including the password (good for loading in an IFRAME). For non-secure reports, this will not be returned 894 | * @returnf string password If secured, the password for the report, otherwise this field will not be returned 895 | */ 896 | function campaignShareReport($cid, $opts=array ( 897 | )) { 898 | $params = array(); 899 | $params["cid"] = $cid; 900 | $params["opts"] = $opts; 901 | return $this->callServer("campaignShareReport", $params); 902 | } 903 | 904 | /** 905 | * Get the content (both html and text) for a campaign either as it would appear in the campaign archive or as the raw, original content 906 | * 907 | * @section Campaign Related 908 | * 909 | * @param string $cid the campaign id to get content for (can be gathered using campaigns()) 910 | * @param bool $for_archive optional controls whether we return the Archive version (true) or the Raw version (false), defaults to true 911 | * @return struct Struct containing all content for the campaign (see Returned Fields for details 912 | * @returnf string html The HTML content used for the campgain with merge tags intact 913 | * @returnf string text The Text content used for the campgain with merge tags intact 914 | */ 915 | function campaignContent($cid, $for_archive=true) { 916 | $params = array(); 917 | $params["cid"] = $cid; 918 | $params["for_archive"] = $for_archive; 919 | return $this->callServer("campaignContent", $params); 920 | } 921 | 922 | /** 923 | * Get the HTML template content sections for a campaign. Note that this will return very jagged, non-standard results based on the template 924 | * a campaign is using. You only want to use this if you want to allow editing template sections in your applicaton. 925 | * 926 | * @section Campaign Related 927 | * 928 | * @param string $cid the campaign id to get content for (can be gathered using campaigns()) 929 | * @return array array containing all content section for the campaign - 930 | */ 931 | function campaignTemplateContent($cid) { 932 | $params = array(); 933 | $params["cid"] = $cid; 934 | return $this->callServer("campaignTemplateContent", $params); 935 | } 936 | 937 | /** 938 | * Retrieve the list of email addresses that opened a given campaign with how many times they opened - note: this AIM function is free and does 939 | * not actually require the AIM module to be installed 940 | * 941 | * @section Campaign Report Data 942 | * 943 | * @param string $cid the campaign id to get opens for (can be gathered using campaigns()) 944 | * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0) 945 | * @param int $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000 946 | * @return array array containing the total records matched and the specific records for this page 947 | * @returnf int total the total number of records matched 948 | * @returnf array data the actual opens data, including: 949 | string email Email address that opened the campaign 950 | int open_count Total number of times the campaign was opened by this email address 951 | */ 952 | function campaignOpenedAIM($cid, $start=0, $limit=1000) { 953 | $params = array(); 954 | $params["cid"] = $cid; 955 | $params["start"] = $start; 956 | $params["limit"] = $limit; 957 | return $this->callServer("campaignOpenedAIM", $params); 958 | } 959 | 960 | /** 961 | * Retrieve the list of email addresses that did not open a given campaign 962 | * 963 | * @section Campaign Report Data 964 | * 965 | * @param string $cid the campaign id to get no opens for (can be gathered using campaigns()) 966 | * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0) 967 | * @param int $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000 968 | * @return array array containing the total records matched and the specific records for this page 969 | * @returnf int total the total number of records matched 970 | * @returnf array data the email addresses that did not open the campaign 971 | string email Email address that opened the campaign 972 | */ 973 | function campaignNotOpenedAIM($cid, $start=0, $limit=1000) { 974 | $params = array(); 975 | $params["cid"] = $cid; 976 | $params["start"] = $start; 977 | $params["limit"] = $limit; 978 | return $this->callServer("campaignNotOpenedAIM", $params); 979 | } 980 | 981 | /** 982 | * Return the list of email addresses that clicked on a given url, and how many times they clicked 983 | * 984 | * @section Campaign Report Data 985 | * 986 | * @param string $cid the campaign id to get click stats for (can be gathered using campaigns()) 987 | * @param string $url the URL of the link that was clicked on 988 | * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0) 989 | * @param int $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000 990 | * @return array array containing the total records matched and the specific records for this page 991 | * @returnf int total the total number of records matched 992 | * @returnf array data the email addresses that did not open the campaign 993 | string email Email address that opened the campaign 994 | int clicks Total number of times the URL was clicked on by this email address 995 | */ 996 | function campaignClickDetailAIM($cid, $url, $start=0, $limit=1000) { 997 | $params = array(); 998 | $params["cid"] = $cid; 999 | $params["url"] = $url; 1000 | $params["start"] = $start; 1001 | $params["limit"] = $limit; 1002 | return $this->callServer("campaignClickDetailAIM", $params); 1003 | } 1004 | 1005 | /** 1006 | * Given a campaign and email address, return the entire click and open history with timestamps, ordered by time 1007 | * 1008 | * @section Campaign Report Data 1009 | * 1010 | * @param string $cid the campaign id to get stats for (can be gathered using campaigns()) 1011 | * @param array $email_address an array of up to 50 email addresses to check OR the email "id" returned from listMemberInfo, Webhooks, and Campaigns. For backwards compatibility, if a string is passed, it will be treated as an array with a single element (will not work with XML-RPC). 1012 | * @return array an array with the keys listed in Returned Fields below 1013 | * @returnf int success the number of email address records found 1014 | * @returnf int error the number of email address records which could not be found 1015 | * @returnf array data arrays containing the actions (opens and clicks) that the email took, with timestamps 1016 | string action The action taken (open or click) 1017 | string timestamp Time the action occurred 1018 | string url For clicks, the URL that was clicked 1019 | */ 1020 | function campaignEmailStatsAIM($cid, $email_address) { 1021 | $params = array(); 1022 | $params["cid"] = $cid; 1023 | $params["email_address"] = $email_address; 1024 | return $this->callServer("campaignEmailStatsAIM", $params); 1025 | } 1026 | 1027 | /** 1028 | * Given a campaign and correct paging limits, return the entire click and open history with timestamps, ordered by time, 1029 | * for every user a campaign was delivered to. 1030 | * 1031 | * @section Campaign Report Data 1032 | * @example mcapi_campaignEmailStatsAIMAll.php 1033 | * 1034 | * @param string $cid the campaign id to get stats for (can be gathered using campaigns()) 1035 | * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0) 1036 | * @param int $limit optional for large data sets, the number of results to return - defaults to 100, upper limit set at 1000 1037 | * @return array Array containing a total record count and data including the actions (opens and clicks) for each email, with timestamps 1038 | * @returnf int total the total number of records 1039 | * @returnf array data each record with their details: 1040 | string action The action taken (open or click) 1041 | string timestamp Time the action occurred 1042 | string url For clicks, the URL that was clicked 1043 | */ 1044 | function campaignEmailStatsAIMAll($cid, $start=0, $limit=100) { 1045 | $params = array(); 1046 | $params["cid"] = $cid; 1047 | $params["start"] = $start; 1048 | $params["limit"] = $limit; 1049 | return $this->callServer("campaignEmailStatsAIMAll", $params); 1050 | } 1051 | 1052 | /** 1053 | * Attach Ecommerce Order Information to a Campaign. This will generall be used by ecommerce package plugins 1054 | * that we provide or by 3rd part system developers. 1055 | * @section Campaign Related 1056 | * 1057 | * @param array $order an array of information pertaining to the order that has completed. Use the following keys: 1058 | string id the Order Id 1059 | string campaign_id the Campaign Id to track this order with (see the "mc_cid" query string variable a campaign passes) 1060 | string email_id the Email Id of the subscriber we should attach this order to (see the "mc_eid" query string variable a campaign passes) 1061 | double total The Order Total (ie, the full amount the customer ends up paying) 1062 | string order_date optional the date of the order - if this is not provided, we will default the date to now 1063 | double shipping optional the total paid for Shipping Fees 1064 | double tax optional the total tax paid 1065 | string store_id a unique id for the store sending the order in (20 bytes max) 1066 | string store_name optional a "nice" name for the store - typically the base web address (ie, "store.mailchimp.com"). We will automatically update this if it changes (based on store_id) 1067 | string plugin_id the MailChimp assigned Plugin Id. Get yours by registering here 1068 | array items the individual line items for an order using these keys: 1069 |
1070 | int line_num optional the line number of the item on the order. We will generate these if they are not passed 1071 | int product_id the store's internal Id for the product. Lines that do no contain this will be skipped 1072 | string product_name the product name for the product_id associated with this item. We will auto update these as they change (based on product_id) 1073 | int category_id the store's internal Id for the (main) category associated with this product. Our testing has found this to be a "best guess" scenario 1074 | string category_name the category name for the category_id this product is in. Our testing has found this to be a "best guess" scenario. Our plugins walk the category heirarchy up and send "Root - SubCat1 - SubCat4", etc. 1075 | double qty the quantity of the item ordered 1076 | double cost the cost of a single item (ie, not the extended cost of the line) 1077 |
1078 | * @return bool true if the data is saved, otherwise an error is thrown. 1079 | */ 1080 | function campaignEcommOrderAdd($order) { 1081 | $params = array(); 1082 | $params["order"] = $order; 1083 | return $this->callServer("campaignEcommOrderAdd", $params); 1084 | } 1085 | 1086 | /** 1087 | * Retrieve all of the lists defined for your user account 1088 | * 1089 | * @section List Related 1090 | * @example mcapi_lists.php 1091 | * @example xml-rpc_lists.php 1092 | * 1093 | * @param array $filters a hash of filters to apply to this query - all are optional: 1094 | string list_id optional - return a single list using a known list_id. Accepts multiples separated by commas when not using exact matching 1095 | string list_name optional - only lists that match this name 1096 | string from_name optional - only lists that have a default from name matching this 1097 | string from_email optional - only lists that have a default from email matching this 1098 | string from_subject optional - only lists that have a default from email matching this 1099 | string created_before optional - only show lists that were created before this date/time (in GMT) - format is YYYY-MM-DD HH:mm:ss (24hr) 1100 | string created_after optional - only show lists that were created since this date/time (in GMT) - format is YYYY-MM-DD HH:mm:ss (24hr) 1101 | boolean exact optional - flag for whether to filter on exact values when filtering, or search within content for filter values - defaults to true 1102 | * @param int $start optional - control paging of lists, start results at this list #, defaults to 1st page of data (page 0) 1103 | * @param int $limit optional - control paging of lists, number of lists to return with each call, defaults to 25 (max=100) 1104 | * @return array an array with keys listed in Returned Fields below 1105 | * @returnf int total the total number of lists which matched the provided filters 1106 | * @returnf array data the lists which matched the provided filters, including the following for 1107 | string id The list id for this list. This will be used for all other list management functions. 1108 | int web_id The list id used in our web app, allows you to create a link directly to it 1109 | string name The name of the list. 1110 | string date_created The date that this list was created. 1111 | boolean email_type_option Whether or not the List supports multiple formats for emails or just HTML 1112 | boolean use_awesomebar Whether or not campaigns for this list use the Awesome Bar in archives by default 1113 | string default_from_name Default From Name for campaigns using this list 1114 | string default_from_email Default From Email for campaigns using this list 1115 | string default_subject Default Subject Line for campaigns using this list 1116 | string default_language Default Language for this list's forms 1117 | int list_rating An auto-generated activity score for the list (0 - 5) 1118 | array stats various stats and counts for the list 1119 | int member_count The number of active members in the given list. 1120 | int unsubscribe_count The number of members who have unsubscribed from the given list. 1121 | int cleaned_count The number of members cleaned from the given list. 1122 | int member_count_since_send The number of active members in the given list since the last campaign was sent 1123 | int unsubscribe_count_since_send The number of members who have unsubscribed from the given list since the last campaign was sent 1124 | int cleaned_count_since_send The number of members cleaned from the given list since the last campaign was sent 1125 | int campaign_count The number of campaigns in any status that use this list 1126 | int grouping_count The number of Interest Groupings for this list 1127 | int group_count The number of Interest Groups (regardless of grouping) for this list 1128 | int merge_var_count The number of merge vars for this list (not including the required EMAIL one) 1129 | int avg_sub_rate the average number of subscribe per month for the list (empty value if we haven't calculated this yet) 1130 | int avg_unsub_rate the average number of unsubscribe per month for the list (empty value if we haven't calculated this yet) 1131 | int target_sub_rate the target subscription rate for the list to keep it growing (empty value if we haven't calculated this yet) 1132 | int open_rate the average open rate per campaign for the list (empty value if we haven't calculated this yet) 1133 | int click_rate the average click rate per campaign for the list (empty value if we haven't calculated this yet) 1134 | array modules Any list specific modules installed for this list (example is SocialPro) 1135 | */ 1136 | function lists($filters=array ( 1137 | ), $start=0, $limit=25) { 1138 | $params = array(); 1139 | $params["filters"] = $filters; 1140 | $params["start"] = $start; 1141 | $params["limit"] = $limit; 1142 | return $this->callServer("lists", $params); 1143 | } 1144 | 1145 | /** 1146 | * Get the list of merge tags for a given list, including their name, tag, and required setting 1147 | * 1148 | * @section List Related 1149 | * @example xml-rpc_listMergeVars.php 1150 | * 1151 | * @param string $id the list id to connect to. Get by calling lists() 1152 | * @return array list of merge tags for the list 1153 | * @returnf string name Name of the merge field 1154 | * @returnf bool req Denotes whether the field is required (true) or not (false) 1155 | * @returnf string field_type The "data type" of this merge var. One of: email, text, number, radio, dropdown, date, address, phone, url, imageurl 1156 | * @returnf bool public Whether or not this field is visible to list subscribers 1157 | * @returnf bool show Whether the list owner has this field displayed on their list dashboard 1158 | * @returnf string order The order the list owner has set this field to display in 1159 | * @returnf string default The default value the list owner has set for this field 1160 | * @returnf string size The width of the field to be used 1161 | * @returnf string tag The merge tag that's used for forms and listSubscribe() and listUpdateMember() 1162 | * @returnf array choices For radio and dropdown field types, an array of the options available 1163 | */ 1164 | function listMergeVars($id) { 1165 | $params = array(); 1166 | $params["id"] = $id; 1167 | return $this->callServer("listMergeVars", $params); 1168 | } 1169 | 1170 | /** 1171 | * Add a new merge tag to a given list 1172 | * 1173 | * @section List Related 1174 | * @example xml-rpc_listMergeVarAdd.php 1175 | * 1176 | * @param string $id the list id to connect to. Get by calling lists() 1177 | * @param string $tag The merge tag to add, e.g. FNAME 1178 | * @param string $name The long description of the tag being added, used for user displays 1179 | * @param array $options optional Various options for this merge var. note: for historical purposes this can also take a "boolean" 1180 | string field_type optional one of: text, number, radio, dropdown, date, address, phone, url, imageurl - defaults to text 1181 | boolean req optional indicates whether the field is required - defaults to false 1182 | boolean public optional indicates whether the field is displayed in public - defaults to true 1183 | boolean show optional indicates whether the field is displayed in the app's list member view - defaults to true 1184 | string default_value optional the default value for the field. See listSubscribe() for formatting info. Defaults to blank 1185 | array choices optional kind of - an array of strings to use as the choices for radio and dropdown type fields 1186 | 1187 | * @return bool true if the request succeeds, otherwise an error will be thrown 1188 | */ 1189 | function listMergeVarAdd($id, $tag, $name, $options=array ( 1190 | )) { 1191 | $params = array(); 1192 | $params["id"] = $id; 1193 | $params["tag"] = $tag; 1194 | $params["name"] = $name; 1195 | $params["options"] = $options; 1196 | return $this->callServer("listMergeVarAdd", $params); 1197 | } 1198 | 1199 | /** 1200 | * Update most parameters for a merge tag on a given list. You cannot currently change the merge type 1201 | * 1202 | * @section List Related 1203 | * 1204 | * @param string $id the list id to connect to. Get by calling lists() 1205 | * @param string $tag The merge tag to update 1206 | * @param array $options The options to change for a merge var. See listMergeVarAdd() for valid options 1207 | * @return bool true if the request succeeds, otherwise an error will be thrown 1208 | */ 1209 | function listMergeVarUpdate($id, $tag, $options) { 1210 | $params = array(); 1211 | $params["id"] = $id; 1212 | $params["tag"] = $tag; 1213 | $params["options"] = $options; 1214 | return $this->callServer("listMergeVarUpdate", $params); 1215 | } 1216 | 1217 | /** 1218 | * Delete a merge tag from a given list and all its members. Seriously - the data is removed from all members as well! 1219 | * Note that on large lists this method may seem a bit slower than calls you typically make. 1220 | * 1221 | * @section List Related 1222 | * @example xml-rpc_listMergeVarDel.php 1223 | * 1224 | * @param string $id the list id to connect to. Get by calling lists() 1225 | * @param string $tag The merge tag to delete 1226 | * @return bool true if the request succeeds, otherwise an error will be thrown 1227 | */ 1228 | function listMergeVarDel($id, $tag) { 1229 | $params = array(); 1230 | $params["id"] = $id; 1231 | $params["tag"] = $tag; 1232 | return $this->callServer("listMergeVarDel", $params); 1233 | } 1234 | 1235 | /** 1236 | * Get the list of interest groupings for a given list, including the label, form information, and included groups for each 1237 | * 1238 | * @section List Related 1239 | * @example xml-rpc_listInterestGroupings.php 1240 | * 1241 | * @param string $id the list id to connect to. Get by calling lists() 1242 | * @return struct list of interest groups for the list 1243 | * @returnf string id The id for the Grouping 1244 | * @returnf string name Name for the Interest groups 1245 | * @returnf string form_field Gives the type of interest group: checkbox,radio,select 1246 | * @returnf array groups Array of the grouping options including the "bit" value, "name", "display_order", and number of "subscribers" with the option selected. 1247 | */ 1248 | function listInterestGroupings($id) { 1249 | $params = array(); 1250 | $params["id"] = $id; 1251 | return $this->callServer("listInterestGroupings", $params); 1252 | } 1253 | 1254 | /** Add a single Interest Group - if interest groups for the List are not yet enabled, adding the first 1255 | * group will automatically turn them on. 1256 | * 1257 | * @section List Related 1258 | * @example xml-rpc_listInterestGroupAdd.php 1259 | * 1260 | * @param string $id the list id to connect to. Get by calling lists() 1261 | * @param string $group_name the interest group to add - group names must be unique within a grouping 1262 | * @param int optional $grouping_id The grouping to add the new group to - get using listInterestGrouping() . If not supplied, the first grouping on the list is used. 1263 | * @return bool true if the request succeeds, otherwise an error will be thrown 1264 | */ 1265 | function listInterestGroupAdd($id, $group_name, $grouping_id=NULL) { 1266 | $params = array(); 1267 | $params["id"] = $id; 1268 | $params["group_name"] = $group_name; 1269 | $params["grouping_id"] = $grouping_id; 1270 | return $this->callServer("listInterestGroupAdd", $params); 1271 | } 1272 | 1273 | /** Delete a single Interest Group - if the last group for a list is deleted, this will also turn groups for the list off. 1274 | * 1275 | * @section List Related 1276 | * @example xml-rpc_listInterestGroupDel.php 1277 | * 1278 | * @param string $id the list id to connect to. Get by calling lists() 1279 | * @param string $group_name the interest group to delete 1280 | * @param int $grouping_id The grouping to delete the group from - get using listInterestGrouping() . If not supplied, the first grouping on the list is used. 1281 | * @return bool true if the request succeeds, otherwise an error will be thrown 1282 | */ 1283 | function listInterestGroupDel($id, $group_name, $grouping_id=NULL) { 1284 | $params = array(); 1285 | $params["id"] = $id; 1286 | $params["group_name"] = $group_name; 1287 | $params["grouping_id"] = $grouping_id; 1288 | return $this->callServer("listInterestGroupDel", $params); 1289 | } 1290 | 1291 | /** Change the name of an Interest Group 1292 | * 1293 | * @section List Related 1294 | * 1295 | * @param string $id the list id to connect to. Get by calling lists() 1296 | * @param string $old_name the interest group name to be changed 1297 | * @param string $new_name the new interest group name to be set 1298 | * @param int optional $grouping_id The grouping to delete the group from - get using listInterestGrouping() . If not supplied, the first grouping on the list is used. 1299 | * @return bool true if the request succeeds, otherwise an error will be thrown 1300 | */ 1301 | function listInterestGroupUpdate($id, $old_name, $new_name, $grouping_id=NULL) { 1302 | $params = array(); 1303 | $params["id"] = $id; 1304 | $params["old_name"] = $old_name; 1305 | $params["new_name"] = $new_name; 1306 | $params["grouping_id"] = $grouping_id; 1307 | return $this->callServer("listInterestGroupUpdate", $params); 1308 | } 1309 | 1310 | /** Add a new Interest Grouping - if interest groups for the List are not yet enabled, adding the first 1311 | * grouping will automatically turn them on. 1312 | * 1313 | * @section List Related 1314 | * @example xml-rpc_listInterestGroupingAdd.php 1315 | * 1316 | * @param string $id the list id to connect to. Get by calling lists() 1317 | * @param string $name the interest grouping to add - grouping names must be unique 1318 | * @param string $type The type of the grouping to add - one of "checkboxes", "hidden", "dropdown", "radio" 1319 | * @param array $groups The lists of initial group names to be added - at least 1 is required and the names must be unique within a grouping. If the number takes you over the 60 group limit, an error will be thrown. 1320 | * @return int the new grouping id if the request succeeds, otherwise an error will be thrown 1321 | */ 1322 | function listInterestGroupingAdd($id, $name, $type, $groups) { 1323 | $params = array(); 1324 | $params["id"] = $id; 1325 | $params["name"] = $name; 1326 | $params["type"] = $type; 1327 | $params["groups"] = $groups; 1328 | return $this->callServer("listInterestGroupingAdd", $params); 1329 | } 1330 | 1331 | /** Update an existing Interest Grouping 1332 | * 1333 | * @section List Related 1334 | * @example xml-rpc_listInterestGroupingUpdate.php 1335 | * 1336 | * @param int $grouping_id the interest grouping id - get from listInterestGroupings() 1337 | * @param string $name The name of the field to update - either "name" or "type". Groups with in the grouping should be manipulated using the standard listInterestGroup* methods 1338 | * @param string $value The new value of the field. Grouping names must be unique - only "hidden" and "checkboxes" grouping types can be converted between each other. 1339 | * @return bool true if the request succeeds, otherwise an error will be thrown 1340 | */ 1341 | function listInterestGroupingUpdate($grouping_id, $name, $value) { 1342 | $params = array(); 1343 | $params["grouping_id"] = $grouping_id; 1344 | $params["name"] = $name; 1345 | $params["value"] = $value; 1346 | return $this->callServer("listInterestGroupingUpdate", $params); 1347 | } 1348 | 1349 | /** Delete an existing Interest Grouping - this will permanently delete all contained interest groups and will remove those selections from all list members 1350 | * 1351 | * @section List Related 1352 | * @example xml-rpc_listInterestGroupingDel.php 1353 | * 1354 | * @param int $grouping_id the interest grouping id - get from listInterestGroupings() 1355 | * @return bool true if the request succeeds, otherwise an error will be thrown 1356 | */ 1357 | function listInterestGroupingDel($grouping_id) { 1358 | $params = array(); 1359 | $params["grouping_id"] = $grouping_id; 1360 | return $this->callServer("listInterestGroupingDel", $params); 1361 | } 1362 | 1363 | /** Return the Webhooks configured for the given list 1364 | * 1365 | * @section List Related 1366 | * 1367 | * @param string $id the list id to connect to. Get by calling lists() 1368 | * @return array list of webhooks 1369 | * @returnf string url the URL for this Webhook 1370 | * @returnf array actions the possible actions and whether they are enabled 1371 | * @returnf array sources the possible sources and whether they are enabled 1372 | */ 1373 | function listWebhooks($id) { 1374 | $params = array(); 1375 | $params["id"] = $id; 1376 | return $this->callServer("listWebhooks", $params); 1377 | } 1378 | 1379 | /** Add a new Webhook URL for the given list 1380 | * 1381 | * @section List Related 1382 | * 1383 | * @param string $id the list id to connect to. Get by calling lists() 1384 | * @param string $url a valid URL for the Webhook - it will be validated. note that a url may only exist on a list once. 1385 | * @param array $actions optional a hash of actions to fire this Webhook for 1386 | boolean subscribe optional as subscribes occur, defaults to true 1387 | boolean unsubscribe optional as subscribes occur, defaults to true 1388 | boolean profile optional as profile updates occur, defaults to true 1389 | boolean cleaned optional as emails are cleaned from the list, defaults to true 1390 | boolean upemail optional when subscribers change their email address, defaults to true 1391 | * @param array $sources optional a hash of sources to fire this Webhook for 1392 | boolean user optional user/subscriber initiated actions, defaults to true 1393 | boolean admin optional admin actions in our web app, defaults to true 1394 | boolean api optional actions that happen via API calls, defaults to false 1395 | * @return bool true if the call succeeds, otherwise an exception will be thrown 1396 | */ 1397 | function listWebhookAdd($id, $url, $actions=array ( 1398 | ), $sources=array ( 1399 | )) { 1400 | $params = array(); 1401 | $params["id"] = $id; 1402 | $params["url"] = $url; 1403 | $params["actions"] = $actions; 1404 | $params["sources"] = $sources; 1405 | return $this->callServer("listWebhookAdd", $params); 1406 | } 1407 | 1408 | /** Delete an existing Webhook URL from a given list 1409 | * 1410 | * @section List Related 1411 | * 1412 | * @param string $id the list id to connect to. Get by calling lists() 1413 | * @param string $url the URL of a Webhook on this list 1414 | * @return boolean true if the call succeeds, otherwise an exception will be thrown 1415 | */ 1416 | function listWebhookDel($id, $url) { 1417 | $params = array(); 1418 | $params["id"] = $id; 1419 | $params["url"] = $url; 1420 | return $this->callServer("listWebhookDel", $params); 1421 | } 1422 | 1423 | /** Retrieve all of the Static Segments for a list. 1424 | * 1425 | * @section List Related 1426 | * 1427 | * @param string $id the list id to connect to. Get by calling lists() 1428 | * @return array an array of parameters for each static segment 1429 | * @returnf int id the id of the segment 1430 | * @returnf string name the name for the segment 1431 | * @returnf int member_count the total number of members currently in a segment 1432 | * @returnf date created_date the date/time the segment was created 1433 | * @returnf date last_update the date/time the segment was last updated (add or del) 1434 | * @returnf date last_reset the date/time the segment was last reset (ie had all members cleared from it) 1435 | */ 1436 | function listStaticSegments($id) { 1437 | $params = array(); 1438 | $params["id"] = $id; 1439 | return $this->callServer("listStaticSegments", $params); 1440 | } 1441 | 1442 | /** Save a segment against a list for later use. There is no limit to the number of segments which can be saved. Static Segments are not tied 1443 | * to any merge data, interest groups, etc. They essentially allow you to configure an unlimited number of custom segments which will have standard performance. 1444 | * When using proper segments, Static Segments are one of the available options for segmentation just as if you used a merge var (and they can be used with other segmentation 1445 | * options), though performance may degrade at that point. 1446 | * 1447 | * @section List Related 1448 | * 1449 | * @param string $id the list id to connect to. Get by calling lists() 1450 | * @param string $name a unique name per list for the segment - 50 byte maximum length, anything longer will throw an error 1451 | * @return int the id of the new segment, otherwise an error will be thrown. 1452 | */ 1453 | function listStaticSegmentAdd($id, $name) { 1454 | $params = array(); 1455 | $params["id"] = $id; 1456 | $params["name"] = $name; 1457 | return $this->callServer("listStaticSegmentAdd", $params); 1458 | } 1459 | 1460 | /** Resets a static segment - removes all members from the static segment. Note: does not actually affect list member data 1461 | * 1462 | * @section List Related 1463 | * 1464 | * @param string $id the list id to connect to. Get by calling lists() 1465 | * @param int $seg_id the id of the static segment to reset - get from listStaticSegments() 1466 | * @return bool true if it worked, otherwise an error is thrown. 1467 | */ 1468 | function listStaticSegmentReset($id, $seg_id) { 1469 | $params = array(); 1470 | $params["id"] = $id; 1471 | $params["seg_id"] = $seg_id; 1472 | return $this->callServer("listStaticSegmentReset", $params); 1473 | } 1474 | 1475 | /** Delete a static segment. Note that this will, of course, remove any member affiliations with the segment 1476 | * 1477 | * @section List Related 1478 | * 1479 | * @param string $id the list id to connect to. Get by calling lists() 1480 | * @param int $seg_id the id of the static segment to delete - get from listStaticSegments() 1481 | * @return bool true if it worked, otherwise an error is thrown. 1482 | */ 1483 | function listStaticSegmentDel($id, $seg_id) { 1484 | $params = array(); 1485 | $params["id"] = $id; 1486 | $params["seg_id"] = $seg_id; 1487 | return $this->callServer("listStaticSegmentDel", $params); 1488 | } 1489 | 1490 | /** Add list members to a static segment. It is suggested that you limit batch size to no more than 10,000 addresses per call. Email addresses must exist on the list 1491 | * in order to be included - this will not subscribe them to the list! 1492 | * 1493 | * @section List Related 1494 | * 1495 | * @param string $id the list id to connect to. Get by calling lists() 1496 | * @param int $seg_id the id of the static segment to modify - get from listStaticSegments() 1497 | * @param array $batch an array of email addresses and/or unique_ids to add to the segment 1498 | * @return array an array with the results of the operation 1499 | * @returnf int success the total number of successful updates (will include members already in the segment) 1500 | * @returnf array errors the email address, an error code, and a message explaining why they couldn't be added 1501 | */ 1502 | function listStaticSegmentMembersAdd($id, $seg_id, $batch) { 1503 | $params = array(); 1504 | $params["id"] = $id; 1505 | $params["seg_id"] = $seg_id; 1506 | $params["batch"] = $batch; 1507 | return $this->callServer("listStaticSegmentMembersAdd", $params); 1508 | } 1509 | 1510 | /** Remove list members from a static segment. It is suggested that you limit batch size to no more than 10,000 addresses per call. Email addresses must exist on the list 1511 | * in order to be removed - this will not unsubscribe them from the list! 1512 | * 1513 | * @section List Related 1514 | * 1515 | * @param string $id the list id to connect to. Get by calling lists() 1516 | * @param int $seg_id the id of the static segment to delete - get from listStaticSegments() 1517 | * @param array $batch an array of email addresses and/or unique_ids to remove from the segment 1518 | * @return array an array with the results of the operation 1519 | * @returnf int success the total number of succesful removals 1520 | * @returnf array errors the email address, an error code, and a message explaining why they couldn't be removed 1521 | */ 1522 | function listStaticSegmentMembersDel($id, $seg_id, $batch) { 1523 | $params = array(); 1524 | $params["id"] = $id; 1525 | $params["seg_id"] = $seg_id; 1526 | $params["batch"] = $batch; 1527 | return $this->callServer("listStaticSegmentMembersDel", $params); 1528 | } 1529 | 1530 | /** 1531 | * Subscribe the provided email to a list. By default this sends a confirmation email - you will not see new members until the link contained in it is clicked! 1532 | * 1533 | * @section List Related 1534 | * 1535 | * @example mcapi_listSubscribe.php 1536 | * @example json_listSubscribe.php 1537 | * @example xml-rpc_listSubscribe.php 1538 | * 1539 | * @param string $id the list id to connect to. Get by calling lists() 1540 | * @param string $email_address the email address to subscribe 1541 | * @param array $merge_vars optional merges for the email (FNAME, LNAME, etc.) (see examples below for handling "blank" arrays). Note that a merge field can only hold up to 255 bytes. Also, there are a few "special" keys: 1542 | string EMAIL set this to change the email address. This is only respected on calls using update_existing or when passed to listUpdateMember() 1543 | array GROUPINGS Set Interest Groups by Grouping. Each element in this array should be an array containing the "groups" parameter which contains a comma delimited list of Interest Groups to add. Commas in Interest Group names should be escaped with a backslash. ie, "," => "\," and either an "id" or "name" parameter to specify the Grouping - get from listInterestGroupings() 1544 | string OPTINIP Set the Opt-in IP fields. Abusing this may cause your account to be suspended. We do validate this and it must not be a private IP address. 1545 | array MC_LOCATION Set the members geographic location. By default if this merge field exists, we'll update using the optin_ip if it exists. If the array contains LATITUDE and LONGITUDE keys, they will be used. NOTE - this will slow down each subscribe call a bit, especially for lat/lng pairs in sparsely populated areas. Currently our automated background processes can and will overwrite this based on opens and clicks. 1546 | 1547 | Handling Field Data Types - most fields you can just pass a string and all is well. For some, though, that is not the case... 1548 | Field values should be formatted as follows: 1549 | string address For the string version of an Address, the fields should be delimited by 2 spaces. Address 2 can be skipped. The Country should be a 2 character ISO-3166-1 code and will default to your default country if not set 1550 | array address For the array version of an Address, the requirements for Address 2 and Country are the same as with the string version. Then simply pass us an array with the keys addr1, addr2, city, state, zip, country and appropriate values for each 1551 | 1552 | string date use YYYY-MM-DD to be safe. Generally, though, anything strtotime() understands we'll understand - http://us2.php.net/strtotime 1553 | string dropdown can be a normal string - we will validate that the value is a valid option 1554 | string image must be a valid, existing url. we will check its existence 1555 | string multi_choice can be a normal string - we will validate that the value is a valid option 1556 | double number pass in a valid number - anything else will turn in to zero (0). Note, this will be rounded to 2 decimal places 1557 | string phone If your account has the US Phone numbers option set, this must be in the form of NPA-NXX-LINE (404-555-1212). If not, we assume an International number and will simply set the field with what ever number is passed in. 1558 | string website This is a standard string, but we will verify that it looks like a valid URL 1559 | 1560 | * @param string $email_type optional email type preference for the email (html, text, or mobile defaults to html) 1561 | * @param bool $double_optin optional flag to control whether a double opt-in confirmation message is sent, defaults to true. Abusing this may cause your account to be suspended. 1562 | * @param bool $update_existing optional flag to control whether a existing subscribers should be updated instead of throwing and error, defaults to false 1563 | * @param bool $replace_interests optional flag to determine whether we replace the interest groups with the groups provided, or we add the provided groups to the member's interest groups (optional, defaults to true) 1564 | * @param bool $send_welcome optional if your double_optin is false and this is true, we will send your lists Welcome Email if this subscribe succeeds - this will *not* fire if we end up updating an existing subscriber. If double_optin is true, this has no effect. defaults to false. 1565 | * @return boolean true on success, false on failure. When using MCAPI.class.php, the value can be tested and error messages pulled from the MCAPI object (see below) 1566 | */ 1567 | function listSubscribe($id, $email_address, $merge_vars=NULL, $email_type='html', $double_optin=true, $update_existing=false, $replace_interests=true, $send_welcome=false) { 1568 | $params = array(); 1569 | $params["id"] = $id; 1570 | $params["email_address"] = $email_address; 1571 | $params["merge_vars"] = $merge_vars; 1572 | $params["email_type"] = $email_type; 1573 | $params["double_optin"] = $double_optin; 1574 | $params["update_existing"] = $update_existing; 1575 | $params["replace_interests"] = $replace_interests; 1576 | $params["send_welcome"] = $send_welcome; 1577 | return $this->callServer("listSubscribe", $params); 1578 | } 1579 | 1580 | /** 1581 | * Unsubscribe the given email address from the list 1582 | * 1583 | * @section List Related 1584 | * @example mcapi_listUnsubscribe.php 1585 | * @example xml-rpc_listUnsubscribe.php 1586 | * 1587 | * @param string $id the list id to connect to. Get by calling lists() 1588 | * @param string $email_address the email address to unsubscribe OR the email "id" returned from listMemberInfo, Webhooks, and Campaigns 1589 | * @param boolean $delete_member flag to completely delete the member from your list instead of just unsubscribing, default to false 1590 | * @param boolean $send_goodbye flag to send the goodbye email to the email address, defaults to true 1591 | * @param boolean $send_notify flag to send the unsubscribe notification email to the address defined in the list email notification settings, defaults to true 1592 | * @return boolean true on success, false on failure. When using MCAPI.class.php, the value can be tested and error messages pulled from the MCAPI object (see below) 1593 | */ 1594 | function listUnsubscribe($id, $email_address, $delete_member=false, $send_goodbye=true, $send_notify=true) { 1595 | $params = array(); 1596 | $params["id"] = $id; 1597 | $params["email_address"] = $email_address; 1598 | $params["delete_member"] = $delete_member; 1599 | $params["send_goodbye"] = $send_goodbye; 1600 | $params["send_notify"] = $send_notify; 1601 | return $this->callServer("listUnsubscribe", $params); 1602 | } 1603 | 1604 | /** 1605 | * Edit the email address, merge fields, and interest groups for a list member. If you are doing a batch update on lots of users, 1606 | * consider using listBatchSubscribe() with the update_existing and possible replace_interests parameter. 1607 | * 1608 | * @section List Related 1609 | * @example mcapi_listUpdateMember.php 1610 | * 1611 | * @param string $id the list id to connect to. Get by calling lists() 1612 | * @param string $email_address the current email address of the member to update OR the "id" for the member returned from listMemberInfo, Webhooks, and Campaigns 1613 | * @param array $merge_vars array of new field values to update the member with. See merge_vars in listSubscribe() for details. 1614 | * @param string $email_type change the email type preference for the member ("html", "text", or "mobile"). Leave blank to keep the existing preference (optional) 1615 | * @param boolean $replace_interests flag to determine whether we replace the interest groups with the updated groups provided, or we add the provided groups to the member's interest groups (optional, defaults to true) 1616 | * @return boolean true on success, false on failure. When using MCAPI.class.php, the value can be tested and error messages pulled from the MCAPI object 1617 | */ 1618 | function listUpdateMember($id, $email_address, $merge_vars, $email_type='', $replace_interests=true) { 1619 | $params = array(); 1620 | $params["id"] = $id; 1621 | $params["email_address"] = $email_address; 1622 | $params["merge_vars"] = $merge_vars; 1623 | $params["email_type"] = $email_type; 1624 | $params["replace_interests"] = $replace_interests; 1625 | return $this->callServer("listUpdateMember", $params); 1626 | } 1627 | 1628 | /** 1629 | * Subscribe a batch of email addresses to a list at once. If you are using a serialized version of the API, we strongly suggest that you 1630 | * only run this method as a POST request, and not a GET request. Maximum batch sizes vary based on the amount of data in each record, 1631 | * though you should cap them at 5k - 10k records, depending on your experience. These calls are also long, so be sure you increase your timeout values. 1632 | * 1633 | * @section List Related 1634 | * 1635 | * @example mcapi_listBatchSubscribe.php 1636 | * @example xml-rpc_listBatchSubscribe.php 1637 | * 1638 | * @param string $id the list id to connect to. Get by calling lists() 1639 | * @param array $batch an array of structs for each address to import with two special keys: "EMAIL" for the email address, and "EMAIL_TYPE" for the email type option (html, text, or mobile) 1640 | * @param boolean $double_optin flag to control whether to send an opt-in confirmation email - defaults to true 1641 | * @param boolean $update_existing flag to control whether to update members that are already subscribed to the list or to return an error, defaults to false (return error) 1642 | * @param boolean $replace_interests flag to determine whether we replace the interest groups with the updated groups provided, or we add the provided groups to the member's interest groups (optional, defaults to true) 1643 | * @return struct Array of result counts and any errors that occurred 1644 | * @returnf int add_count Number of email addresses that were succesfully added 1645 | * @returnf int update_count Number of email addresses that were succesfully updated 1646 | * @returnf int error_count Number of email addresses that failed during addition/updating 1647 | * @returnf array errors Array of error arrays, each containing: 1648 | string code the error code 1649 | string message the full error message 1650 | string email the email address being processed 1651 | */ 1652 | function listBatchSubscribe($id, $batch, $double_optin=true, $update_existing=false, $replace_interests=true) { 1653 | $params = array(); 1654 | $params["id"] = $id; 1655 | $params["batch"] = $batch; 1656 | $params["double_optin"] = $double_optin; 1657 | $params["update_existing"] = $update_existing; 1658 | $params["replace_interests"] = $replace_interests; 1659 | return $this->callServer("listBatchSubscribe", $params); 1660 | } 1661 | 1662 | /** 1663 | * Unsubscribe a batch of email addresses to a list 1664 | * 1665 | * @section List Related 1666 | * @example mcapi_listBatchUnsubscribe.php 1667 | * 1668 | * @param string $id the list id to connect to. Get by calling lists() 1669 | * @param array $emails array of email addresses to unsubscribe 1670 | * @param boolean $delete_member flag to completely delete the member from your list instead of just unsubscribing, default to false 1671 | * @param boolean $send_goodbye flag to send the goodbye email to the email addresses, defaults to true 1672 | * @param boolean $send_notify flag to send the unsubscribe notification email to the address defined in the list email notification settings, defaults to false 1673 | * @return struct Array of result counts and any errors that occurred 1674 | * @returnf int success_count Number of email addresses that were succesfully added/updated 1675 | * @returnf int error_count Number of email addresses that failed during addition/updating 1676 | * @returnf array errors Array of error structs. Each error struct will contain "code", "message", and "email" 1677 | */ 1678 | function listBatchUnsubscribe($id, $emails, $delete_member=false, $send_goodbye=true, $send_notify=false) { 1679 | $params = array(); 1680 | $params["id"] = $id; 1681 | $params["emails"] = $emails; 1682 | $params["delete_member"] = $delete_member; 1683 | $params["send_goodbye"] = $send_goodbye; 1684 | $params["send_notify"] = $send_notify; 1685 | return $this->callServer("listBatchUnsubscribe", $params); 1686 | } 1687 | 1688 | /** 1689 | * Get all of the list members for a list that are of a particular status. Are you trying to get a dump including lots of merge 1690 | * data or specific members of a list? If so, checkout the Export API 1691 | * 1692 | * @section List Related 1693 | * @example mcapi_listMembers.php 1694 | * 1695 | * @param string $id the list id to connect to. Get by calling lists() 1696 | * @param string $status the status to get members for - one of(subscribed, unsubscribed, cleaned, updated), defaults to subscribed 1697 | * @param string $since optional pull all members whose status (subscribed/unsubscribed/cleaned) has changed or whose profile (updated) has changed since this date/time (in GMT) - format is YYYY-MM-DD HH:mm:ss (24hr) 1698 | * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0) 1699 | * @param int $limit optional for large data sets, the number of results to return - defaults to 100, upper limit set at 15000 1700 | * @return array Array of a the total records match and matching list member data for this page (see Returned Fields for details) 1701 | * @returnf int total the total matching records 1702 | * @returnf array data the data for each member, including: 1703 | string email Member email address 1704 | date timestamp timestamp of their associated status date (subscribed, unsubscribed, cleaned, or updated) in GMT 1705 | string reason For unsubscribes only - the reason collected for the unsubscribe. If populated, one of 'NORMAL','NOSIGNUP','INAPPROPRIATE','SPAM','OTHER' 1706 | string reason_text For unsubscribes only - if the reason is OTHER, the text entered. 1707 | */ 1708 | function listMembers($id, $status='subscribed', $since=NULL, $start=0, $limit=100) { 1709 | $params = array(); 1710 | $params["id"] = $id; 1711 | $params["status"] = $status; 1712 | $params["since"] = $since; 1713 | $params["start"] = $start; 1714 | $params["limit"] = $limit; 1715 | return $this->callServer("listMembers", $params); 1716 | } 1717 | 1718 | /** 1719 | * Get all the information for particular members of a list 1720 | * 1721 | * @section List Related 1722 | * @example mcapi_listMemberInfo.php 1723 | * @example xml-rpc_listMemberInfo.php 1724 | * 1725 | * @param string $id the list id to connect to. Get by calling lists() 1726 | * @param array $email_address an array of up to 50 email addresses to get information for OR the "id"(s) for the member returned from listMembers, Webhooks, and Campaigns. For backwards compatibility, if a string is passed, it will be treated as an array with a single element (will not work with XML-RPC). 1727 | * @return array array of list members with their info in an array (see Returned Fields for details) 1728 | * @returnf int success the number of subscribers successfully found on the list 1729 | * @returnf int errors the number of subscribers who were not found on the list 1730 | * @returnf array data an array of arrays where each one has member info: 1731 | string id The unique id for this email address on an account 1732 | string email The email address associated with this record 1733 | string email_type The type of emails this customer asked to get: html, text, or mobile 1734 | array merges An associative array of all the merge tags and the data for those tags for this email address. Note: Interest Groups are returned as comma delimited strings - if a group name contains a comma, it will be escaped with a backslash. ie, "," => "\,". Groupings will be returned with their "id" and "name" as well as a "groups" field formatted just like Interest Groups 1735 | string status The subscription status for this email address, either pending, subscribed, unsubscribed, or cleaned 1736 | string ip_opt IP Address this address opted in from. 1737 | string ip_signup IP Address this address signed up from. 1738 | int member_rating the rating of the subscriber. This will be 1 - 5 as described here 1739 | string campaign_id If the user is unsubscribed and they unsubscribed from a specific campaign, that campaign_id will be listed, otherwise this is not returned. 1740 | array lists An associative array of the other lists this member belongs to - the key is the list id and the value is their status in that list. 1741 | date timestamp The time this email address was added to the list 1742 | date info_changed The last time this record was changed. If the record is old enough, this may be blank. 1743 | int web_id The Member id used in our web app, allows you to create a link directly to it 1744 | array clients the various clients we've tracked the address as using - each included array includes client 'name' and 'icon_url' 1745 | array static_segments the 'id', 'name', and date 'added' for any static segment this member is in 1746 | */ 1747 | function listMemberInfo($id, $email_address) { 1748 | $params = array(); 1749 | $params["id"] = $id; 1750 | $params["email_address"] = $email_address; 1751 | return $this->callServer("listMemberInfo", $params); 1752 | } 1753 | 1754 | /** 1755 | * Get the most recent 100 activities for particular list members (open, click, bounce, unsub, abuse, sent to) 1756 | * 1757 | * @section List Related 1758 | * @example mcapi_listMemberInfo.php 1759 | * @example xml-rpc_listMemberInfo.php 1760 | * 1761 | * @param string $id the list id to connect to. Get by calling lists() 1762 | * @param array $email_address an array of up to 50 email addresses to get information for OR the "id"(s) for the member returned from listMembers, Webhooks, and Campaigns. 1763 | * @return array array of data and success/error counts 1764 | * @returnf int success the number of subscribers successfully found on the list 1765 | * @returnf int errors the number of subscribers who were not found on the list 1766 | * @returnf array data an array of arrays where each activity record has: 1767 | string action The action name, one of: open, click, bounce, unsub, abuse, sent 1768 | string timestamp The date/time of the action 1769 | string url For click actions, the url clicked, otherwise this is empty 1770 | string bounce_type For bounce actions, the bounce type, otherwise this is empty 1771 | string campaign_id The campaign id the action was related to, if it exists - otherwise empty (ie, direct unsub from list) 1772 | */ 1773 | function listMemberActivity($id, $email_address) { 1774 | $params = array(); 1775 | $params["id"] = $id; 1776 | $params["email_address"] = $email_address; 1777 | return $this->callServer("listMemberActivity", $params); 1778 | } 1779 | 1780 | /** 1781 | * Get all email addresses that complained about a given campaign 1782 | * 1783 | * @section List Related 1784 | * 1785 | * @example mcapi_listAbuseReports.php 1786 | * 1787 | * @param string $id the list id to pull abuse reports for (can be gathered using lists()) 1788 | * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0) 1789 | * @param int $limit optional for large data sets, the number of results to return - defaults to 500, upper limit set at 1000 1790 | * @param string $since optional pull only messages since this time - use YYYY-MM-DD HH:II:SS format in GMT 1791 | * @return array the total of all reports and the specific reports reports this page 1792 | * @returnf int total the total number of matching abuse reports 1793 | * @returnf array data the actual data for each reports, including: 1794 | string date date/time the abuse report was received and processed 1795 | string email the email address that reported abuse 1796 | string campaign_id the unique id for the campaign that report was made against 1797 | string type an internal type generally specifying the orginating mail provider - may not be useful outside of filling report views 1798 | */ 1799 | function listAbuseReports($id, $start=0, $limit=500, $since=NULL) { 1800 | $params = array(); 1801 | $params["id"] = $id; 1802 | $params["start"] = $start; 1803 | $params["limit"] = $limit; 1804 | $params["since"] = $since; 1805 | return $this->callServer("listAbuseReports", $params); 1806 | } 1807 | 1808 | /** 1809 | * Access the Growth History by Month for a given list. 1810 | * 1811 | * @section List Related 1812 | * 1813 | * @example mcapi_listGrowthHistory.php 1814 | * 1815 | * @param string $id the list id to connect to. Get by calling lists() 1816 | * @return array array of months and growth 1817 | * @returnf string month The Year and Month in question using YYYY-MM format 1818 | * @returnf int existing number of existing subscribers to start the month 1819 | * @returnf int imports number of subscribers imported during the month 1820 | * @returnf int optins number of subscribers who opted-in during the month 1821 | */ 1822 | function listGrowthHistory($id) { 1823 | $params = array(); 1824 | $params["id"] = $id; 1825 | return $this->callServer("listGrowthHistory", $params); 1826 | } 1827 | 1828 | /** 1829 | * Access up to the previous 180 days of daily detailed aggregated activity stats for a given list 1830 | * 1831 | * @section List Related 1832 | * 1833 | * 1834 | * @param string $id the list id to connect to. Get by calling lists() 1835 | * @return array array of array of daily values, each containing: 1836 | * @returnf string day The day in YYYY-MM-DD 1837 | * @returnf int emails_sent number of emails sent to the list 1838 | * @returnf int unique_opens number of unique opens for the list 1839 | * @returnf int recipient_clicks number of clicks for the list 1840 | * @returnf int hard_bounce number of hard bounces for the list 1841 | * @returnf int soft_bounce number of soft bounces for the list 1842 | * @returnf int abuse_reports number of abuse reports for the list 1843 | * @returnf int subs number of double optin subscribes for the list 1844 | * @returnf int unsubs number of manual unsubscribes for the list 1845 | * @returnf int other_adds number of non-double optin subscribes for the list (manual, API, or import) 1846 | * @returnf int other_removes number of non-manual unsubscribes for the list (deletions, empties, soft-bounce removals) 1847 | */ 1848 | function listActivity($id) { 1849 | $params = array(); 1850 | $params["id"] = $id; 1851 | return $this->callServer("listActivity", $params); 1852 | } 1853 | 1854 | /** 1855 | * Retrieve the locations (countries) that the list's subscribers have been tagged to based on geocoding their IP address 1856 | * 1857 | * @section List Related 1858 | * 1859 | * @param string $id the list id to connect to. Get by calling lists() 1860 | * @return array array of locations 1861 | * @returnf string country the country name 1862 | * @returnf string cc the 2 digit country code 1863 | * @returnf double percent the percent of subscribers in the country 1864 | * @returnf double total the total number of subscribers in the country 1865 | */ 1866 | function listLocations($id) { 1867 | $params = array(); 1868 | $params["id"] = $id; 1869 | return $this->callServer("listLocations", $params); 1870 | } 1871 | 1872 | /** 1873 | * Retrieve the clients that the list's subscribers have been tagged as being used based on user agents seen. Made possible by user-agent-string.info 1874 | * 1875 | * @section List Related 1876 | * 1877 | * @param string $id the list id to connect to. Get by calling lists() 1878 | * @return array the desktop and mobile user agents in use on the list 1879 | * @returnf array desktop desktop user agents and percentages 1880 | double penetration the percent of desktop clients in use 1881 | array clients a record containing the 'client', an 'icon' image url, the 'percent' using the client, and the total 'members' represented 1882 | * @returnf array mobile mobile user agents and percentages 1883 | double penetration the percent of mobile clients in use 1884 | array clients a record containing the 'client', an 'icon' image url, the 'percent' using the client, and the total 'members' represented 1885 | */ 1886 | function listClients($id) { 1887 | $params = array(); 1888 | $params["id"] = $id; 1889 | return $this->callServer("listClients", $params); 1890 | } 1891 | 1892 | /** 1893 | * Retrieve various templates available in the system, allowing some thing similar to our template gallery to be created. 1894 | * 1895 | * @section Template Related 1896 | * @example mcapi_templates.php 1897 | * @example xml-rpc_templates.php 1898 | * 1899 | * @param array $types optional the types of templates to return 1900 | boolean user Customer template for this user account. Defaults to true. 1901 | boolean gallery Templates from our Gallery. Note that some templates that require extra configuration are withheld. (eg, the Etsy template). Defaults to false. 1902 | boolean base Our "start from scratch" extremely basic templates 1903 | * @param string $category optional for Gallery templates only, limit to a specific template category 1904 | * @param array $inactives optional options to control how inactive templates are returned, if at all 1905 | boolean include user templates are not deleted, only set inactive. defaults to false. 1906 | boolean only only include inactive templates. defaults to false. 1907 | * @return array An array of structs, one for each template (see Returned Fields for details) 1908 | * @returnf int id Id of the template 1909 | * @returnf string name Name of the template 1910 | * @returnf string layout Layout of the template - "basic", "left_column", "right_column", or "postcard" 1911 | * @returnf string preview_image If we've generated it, the url of the preview image for the template. We do out best to keep these up to date, but Preview image urls are not guaranteed to be available 1912 | * @returnf string date_created The date/time the template was created 1913 | * @returnf bool edit_source Whether or not you are able to edit the source of a template. 1914 | */ 1915 | function templates($types=array ( 1916 | ), $category=NULL, $inactives=array ( 1917 | )) { 1918 | $params = array(); 1919 | $params["types"] = $types; 1920 | $params["category"] = $category; 1921 | $params["inactives"] = $inactives; 1922 | return $this->callServer("templates", $params); 1923 | } 1924 | 1925 | /** 1926 | * Pull details for a specific template to help support editing 1927 | * 1928 | * @section Template Related 1929 | * 1930 | * @param int $tid the template id - get from templates() 1931 | * @param string $type the template type to load - one of 'user', 'gallery', 'base' 1932 | * @return array an array of info to be used when editing 1933 | * @returnf array default_content the default content broken down into the named editable sections for the template 1934 | * @returnf array sections the valid editable section names 1935 | * @returnf string source the full source of the template as if you exported it via our template editor 1936 | * @returnf string preview similar to the source, but the rendered version of the source from our popup preview 1937 | */ 1938 | function templateInfo($tid, $type='user') { 1939 | $params = array(); 1940 | $params["tid"] = $tid; 1941 | $params["type"] = $type; 1942 | return $this->callServer("templateInfo", $params); 1943 | } 1944 | 1945 | /** 1946 | * Create a new user template, NOT campaign content. These templates can then be applied while creating campaigns. 1947 | * 1948 | * @section Template Related 1949 | * @example mcapi_create_template.php 1950 | * @example xml-rpc_create_template.php 1951 | * 1952 | * @param string $name the name for the template - names must be unique and a max of 50 bytes 1953 | * @param string $html a string specifying the entire template to be created. This is NOT campaign content. They are intended to utilize our template language. 1954 | * @return int the new template id, otherwise an error is thrown. 1955 | */ 1956 | function templateAdd($name, $html) { 1957 | $params = array(); 1958 | $params["name"] = $name; 1959 | $params["html"] = $html; 1960 | return $this->callServer("templateAdd", $params); 1961 | } 1962 | 1963 | /** 1964 | * Replace the content of a user template, NOT campaign content. 1965 | * 1966 | * @section Template Related 1967 | * 1968 | * @param int $id the id of the user template to update 1969 | * @param array $values the values to updates - while both are optional, at least one should be provided. Both can be updated at the same time. 1970 | string name optional the name for the template - names must be unique and a max of 50 bytes 1971 | string html optional a string specifying the entire template to be created. This is NOT campaign content. They are intended to utilize our template language. 1972 | 1973 | * @return boolean true if the template was updated, otherwise an error will be thrown 1974 | */ 1975 | function templateUpdate($id, $values) { 1976 | $params = array(); 1977 | $params["id"] = $id; 1978 | $params["values"] = $values; 1979 | return $this->callServer("templateUpdate", $params); 1980 | } 1981 | 1982 | /** 1983 | * Delete (deactivate) a user template 1984 | * 1985 | * @section Template Related 1986 | * 1987 | * @param int $id the id of the user template to delete 1988 | * @return boolean true if the template was deleted, otherwise an error will be thrown 1989 | */ 1990 | function templateDel($id) { 1991 | $params = array(); 1992 | $params["id"] = $id; 1993 | return $this->callServer("templateDel", $params); 1994 | } 1995 | 1996 | /** 1997 | * Undelete (reactivate) a user template 1998 | * 1999 | * @section Template Related 2000 | * 2001 | * @param int $id the id of the user template to reactivate 2002 | * @return boolean true if the template was deleted, otherwise an error will be thrown 2003 | */ 2004 | function templateUndel($id) { 2005 | $params = array(); 2006 | $params["id"] = $id; 2007 | return $this->callServer("templateUndel", $params); 2008 | } 2009 | 2010 | /** 2011 | * Retrieve lots of account information including payments made, plan info, some account stats, installed modules, 2012 | * contact info, and more. No private information like Credit Card numbers is available. 2013 | * 2014 | * @section Helper 2015 | * 2016 | * @return array containing the details for the account tied to this API Key 2017 | * @returnf string username The Account username 2018 | * @returnf string user_id The Account user unique id (for building some links) 2019 | * @returnf bool is_trial Whether the Account is in Trial mode (can only send campaigns to less than 100 emails) 2020 | * @returnf string timezone The timezone for the Account - default is "US/Eastern" 2021 | * @returnf string plan_type Plan Type - "monthly", "payasyougo", or "free" 2022 | * @returnf int plan_low only for Monthly plans - the lower tier for list size 2023 | * @returnf int plan_high only for Monthly plans - the upper tier for list size 2024 | * @returnf string plan_start_date only for Monthly plans - the start date for a monthly plan 2025 | * @returnf int emails_left only for Free and Pay-as-you-go plans emails credits left for the account 2026 | * @returnf bool pending_monthly Whether the account is finishing Pay As You Go credits before switching to a Monthly plan 2027 | * @returnf string first_payment date of first payment 2028 | * @returnf string last_payment date of most recent payment 2029 | * @returnf int times_logged_in total number of times the account has been logged into via the web 2030 | * @returnf string last_login date/time of last login via the web 2031 | * @returnf string affiliate_link Monkey Rewards link for our Affiliate program 2032 | * @returnf array contact Contact details for the account 2033 | string fname First Name 2034 | string lname Last Name 2035 | string email Email Address 2036 | string company Company Name 2037 | string address1 Address Line 1 2038 | string address2 Address Line 2 2039 | string city City 2040 | string state State or Province 2041 | string zip Zip or Postal Code 2042 | string country Country name 2043 | string url Website URL 2044 | string phone Phone number 2045 | string fax Fax number 2046 | * @returnf array modules Addons installed in the account 2047 | string name The module name 2048 | string added The date the module was added 2049 | * @returnf array orders Order details for the account 2050 | int order_id The order id 2051 | string type The order type - either "monthly" or "credits" 2052 | double amount The order amount 2053 | string date The order date 2054 | double credits_used The total credits used 2055 | * @returnf array rewards Rewards details for the account including credits & inspections earned, number of referals, referal details, and rewards used 2056 | int referrals_this_month the total number of referrals this month 2057 | string notify_on whether or not we notify the user when rewards are earned 2058 | string notify_email the email address address used for rewards notifications 2059 | array credits Email credits earned "this_month", "total_earned", and "remaining" 2060 | array inspections Inbox Inspections earned "this_month", "total_earned", and "remaining" 2061 | array referrals All referrals, including "name", "email", "signup_date", and "type" 2062 | array applied Applied rewards, including "value", "date", "order_id", and "order_desc" 2063 | */ 2064 | function getAccountDetails() { 2065 | $params = array(); 2066 | return $this->callServer("getAccountDetails", $params); 2067 | } 2068 | 2069 | /** 2070 | * Have HTML content auto-converted to a text-only format. You can send: plain HTML, an array of Template content, an existing Campaign Id, or an existing Template Id. Note that this will not save anything to or update any of your lists, campaigns, or templates. 2071 | * 2072 | * @section Helper 2073 | * @example xml-rpc_generateText.php 2074 | * 2075 | * @param string $type The type of content to parse. Must be one of: "html", "template", "url", "cid" (Campaign Id), or "tid" (Template Id) 2076 | * @param mixed $content The content to use. For "html" expects a single string value, "template" expects an array like you send to campaignCreate, "url" expects a valid & public URL to pull from, "cid" expects a valid Campaign Id, and "tid" expects a valid Template Id on your account. 2077 | * @return string the content pass in converted to text. 2078 | */ 2079 | function generateText($type, $content) { 2080 | $params = array(); 2081 | $params["type"] = $type; 2082 | $params["content"] = $content; 2083 | return $this->callServer("generateText", $params); 2084 | } 2085 | 2086 | /** 2087 | * Send your HTML content to have the CSS inlined and optionally remove the original styles. 2088 | * 2089 | * @section Helper 2090 | * @example xml-rpc_inlineCss.php 2091 | * 2092 | * @param string $html Your HTML content 2093 | * @param bool $strip_css optional Whether you want the CSS <style> tags stripped from the returned document. Defaults to false. 2094 | * @return string Your HTML content with all CSS inlined, just like if we sent it. 2095 | */ 2096 | function inlineCss($html, $strip_css=false) { 2097 | $params = array(); 2098 | $params["html"] = $html; 2099 | $params["strip_css"] = $strip_css; 2100 | return $this->callServer("inlineCss", $params); 2101 | } 2102 | 2103 | /** 2104 | * List all the folders for a user account 2105 | * 2106 | * @section Folder Related 2107 | * @example mcapi_folders.php 2108 | * @example xml-rpc_folders.php 2109 | * 2110 | * @param string $type optional the type of folders to return - either "campaign" or "autoresponder". Defaults to "campaign" 2111 | * @return array Array of folder structs (see Returned Fields for details) 2112 | * @returnf int folder_id Folder Id for the given folder, this can be used in the campaigns() function to filter on. 2113 | * @returnf string name Name of the given folder 2114 | * @returnf string date_created The date/time the folder was created 2115 | * @returnf string type The type of the folders being returned, just to make sure you know. 2116 | */ 2117 | function folders($type='campaign') { 2118 | $params = array(); 2119 | $params["type"] = $type; 2120 | return $this->callServer("folders", $params); 2121 | } 2122 | 2123 | /** 2124 | * Add a new folder to file campaigns or autoresponders in 2125 | * 2126 | * @section Folder Related 2127 | * @example mcapi_folderAdd.php 2128 | * @example xml-rpc_folderAdd.php 2129 | * 2130 | * @param string $name a unique name for a folder (max 100 bytes) 2131 | * @param string $type optional the type of folder to create - either "campaign" or "autoresponder". Defaults to "campaign" 2132 | * @return int the folder_id of the newly created folder. 2133 | */ 2134 | function folderAdd($name, $type='campaign') { 2135 | $params = array(); 2136 | $params["name"] = $name; 2137 | $params["type"] = $type; 2138 | return $this->callServer("folderAdd", $params); 2139 | } 2140 | 2141 | /** 2142 | * Update the name of a folder for campaigns or autoresponders 2143 | * 2144 | * @section Folder Related 2145 | * 2146 | * @param int $fid the folder id to update - retrieve from folders() 2147 | * @param string $name a new, unique name for the folder (max 100 bytes) 2148 | * @param string $type optional the type of folder to create - either "campaign" or "autoresponder". Defaults to "campaign" 2149 | * @return bool true if the update worked, otherwise an exception is thrown 2150 | */ 2151 | function folderUpdate($fid, $name, $type='campaign') { 2152 | $params = array(); 2153 | $params["fid"] = $fid; 2154 | $params["name"] = $name; 2155 | $params["type"] = $type; 2156 | return $this->callServer("folderUpdate", $params); 2157 | } 2158 | 2159 | /** 2160 | * Delete a campaign or autoresponder folder. Note that this will simply make campaigns in the folder appear unfiled, they are not removed. 2161 | * 2162 | * @section Folder Related 2163 | * 2164 | * @param int $fid the folder id to update - retrieve from folders() 2165 | * @param string $type optional the type of folder to create - either "campaign" or "autoresponder". Defaults to "campaign" 2166 | * @return bool true if the delete worked, otherwise an exception is thrown 2167 | */ 2168 | function folderDel($fid, $type='campaign') { 2169 | $params = array(); 2170 | $params["fid"] = $fid; 2171 | $params["type"] = $type; 2172 | return $this->callServer("folderDel", $params); 2173 | } 2174 | 2175 | /** 2176 | * Retrieve the Ecommerce Orders for an account 2177 | * 2178 | * @section Ecommerce 2179 | * 2180 | * @param int $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0) 2181 | * @param int $limit optional for large data sets, the number of results to return - defaults to 100, upper limit set at 500 2182 | * @param string $since optional pull only messages since this time - use YYYY-MM-DD HH:II:SS format in GMT 2183 | * @return array the total matching orders and the specific orders for the requested page 2184 | * @returnf int total the total matching orders 2185 | * @returnf array data the actual data for each order being returned 2186 | string store_id the store id generated by the plugin used to uniquely identify a store 2187 | string store_name the store name collected by the plugin - often the domain name 2188 | string order_id the internal order id the store tracked this order by 2189 | string email the email address that received this campaign and is associated with this order 2190 | double order_total the order total 2191 | double tax_total the total tax for the order (if collected) 2192 | double ship_total the shipping total for the order (if collected) 2193 | string order_date the date the order was tracked - from the store if possible, otherwise the GMT time we recieved it 2194 | array lines containing detail of the order - product, category, quantity, item cost 2195 | */ 2196 | function ecommOrders($start=0, $limit=100, $since=NULL) { 2197 | $params = array(); 2198 | $params["start"] = $start; 2199 | $params["limit"] = $limit; 2200 | $params["since"] = $since; 2201 | return $this->callServer("ecommOrders", $params); 2202 | } 2203 | 2204 | /** 2205 | * Import Ecommerce Order Information to be used for Segmentation. This will generally be used by ecommerce package plugins 2206 | * that we provide or by 3rd part system developers. 2207 | * @section Ecommerce 2208 | * 2209 | * @param array $order an array of information pertaining to the order that has completed. Use the following keys: 2210 | string id the Order Id 2211 | string email_id optional (kind of) the Email Id of the subscriber we should attach this order to (see the "mc_eid" query string variable a campaign passes) - either this or email is required. If both are provided, email_id takes precedence 2212 | string email optional (kind of) the Email Address we should attach this order to - either this or email_id is required. If both are provided, email_id takes precedence 2213 | double total The Order Total (ie, the full amount the customer ends up paying) 2214 | string order_date optional the date of the order - if this is not provided, we will default the date to now 2215 | double shipping optional the total paid for Shipping Fees 2216 | double tax optional the total tax paid 2217 | string store_id a unique id for the store sending the order in (20 bytes max) 2218 | string store_name optional a "nice" name for the store - typically the base web address (ie, "store.mailchimp.com"). We will automatically update this if it changes (based on store_id) 2219 | string plugin_id the MailChimp assigned Plugin Id. Get yours by registering here 2220 | string campaign_id optional the Campaign Id to track this order with (see the "mc_cid" query string variable a campaign passes) 2221 | array items the individual line items for an order using these keys: 2222 |
2223 | int line_num optional the line number of the item on the order. We will generate these if they are not passed 2224 | int product_id the store's internal Id for the product. Lines that do no contain this will be skipped 2225 | string product_name the product name for the product_id associated with this item. We will auto update these as they change (based on product_id) 2226 | int category_id the store's internal Id for the (main) category associated with this product. Our testing has found this to be a "best guess" scenario 2227 | string category_name the category name for the category_id this product is in. Our testing has found this to be a "best guess" scenario. Our plugins walk the category heirarchy up and send "Root - SubCat1 - SubCat4", etc. 2228 | double qty the quantity of the item ordered 2229 | double cost the cost of a single item (ie, not the extended cost of the line) 2230 |
2231 | * @return bool true if the data is saved, otherwise an error is thrown. 2232 | */ 2233 | function ecommOrderAdd($order) { 2234 | $params = array(); 2235 | $params["order"] = $order; 2236 | return $this->callServer("ecommOrderAdd", $params); 2237 | } 2238 | 2239 | /** 2240 | * Delete Ecommerce Order Information used for segmentation. This will generally be used by ecommerce package plugins 2241 | * that we provide or by 3rd part system developers. 2242 | * @section Ecommerce 2243 | * 2244 | * @param string $store_id the store id the order belongs to 2245 | * @param string $order_id the order id (generated by the store) to delete 2246 | * @return bool true if an order is deleted, otherwise an error is thrown. 2247 | */ 2248 | function ecommOrderDel($store_id, $order_id) { 2249 | $params = array(); 2250 | $params["store_id"] = $store_id; 2251 | $params["order_id"] = $order_id; 2252 | return $this->callServer("ecommOrderDel", $params); 2253 | } 2254 | 2255 | /** 2256 | * Retrieve all List Ids a member is subscribed to. 2257 | * 2258 | * @section Helper 2259 | * 2260 | * @param string $email_address the email address to check OR the email "id" returned from listMemberInfo, Webhooks, and Campaigns 2261 | * @return array An array of list_ids the member is subscribed to. 2262 | */ 2263 | function listsForEmail($email_address) { 2264 | $params = array(); 2265 | $params["email_address"] = $email_address; 2266 | return $this->callServer("listsForEmail", $params); 2267 | } 2268 | 2269 | /** 2270 | * Retrieve all Campaigns Ids a member was sent 2271 | * 2272 | * @section Helper 2273 | * 2274 | * @param string $email_address the email address to unsubscribe OR the email "id" returned from listMemberInfo, Webhooks, and Campaigns 2275 | * @return array An array of campaign_ids the member received 2276 | */ 2277 | function campaignsForEmail($email_address) { 2278 | $params = array(); 2279 | $params["email_address"] = $email_address; 2280 | return $this->callServer("campaignsForEmail", $params); 2281 | } 2282 | 2283 | /** 2284 | * Return the current Chimp Chatter messages for an account. 2285 | * 2286 | * @section Helper 2287 | * 2288 | * @return array An array of chatter messages and properties 2289 | * @returnf string message The chatter message 2290 | * @returnf string type The type of the message - one of lists:new-subscriber, lists:unsubscribes, lists:profile-updates, campaigns:facebook-likes, campaigns:facebook-comments, campaigns:forward-to-friend, lists:imports, or campaigns:inbox-inspections 2291 | * @returnf string url a url into the web app that the message could link to 2292 | * @returnf string list_id the list_id a message relates to, if applicable 2293 | * @returnf string campaign_id the list_id a message relates to, if applicable 2294 | * @returnf string update_time The date/time the message was last updated 2295 | */ 2296 | function chimpChatter() { 2297 | $params = array(); 2298 | return $this->callServer("chimpChatter", $params); 2299 | } 2300 | 2301 | /** 2302 | * Retrieve a list of all MailChimp API Keys for this User 2303 | * 2304 | * @section Security Related 2305 | * @example xml-rpc_apikeyAdd.php 2306 | * @example mcapi_apikeyAdd.php 2307 | * 2308 | * @param string $username Your MailChimp user name 2309 | * @param string $password Your MailChimp password 2310 | * @param boolean $expired optional - whether or not to include expired keys, defaults to false 2311 | * @return array an array of API keys including: 2312 | * @returnf string apikey The api key that can be used 2313 | * @returnf string created_at The date the key was created 2314 | * @returnf string expired_at The date the key was expired 2315 | */ 2316 | function apikeys($username, $password, $expired=false) { 2317 | $params = array(); 2318 | $params["username"] = $username; 2319 | $params["password"] = $password; 2320 | $params["expired"] = $expired; 2321 | return $this->callServer("apikeys", $params); 2322 | } 2323 | 2324 | /** 2325 | * Add an API Key to your account. We will generate a new key for you and return it. 2326 | * 2327 | * @section Security Related 2328 | * @example xml-rpc_apikeyAdd.php 2329 | * 2330 | * @param string $username Your MailChimp user name 2331 | * @param string $password Your MailChimp password 2332 | * @return string a new API Key that can be immediately used. 2333 | */ 2334 | function apikeyAdd($username, $password) { 2335 | $params = array(); 2336 | $params["username"] = $username; 2337 | $params["password"] = $password; 2338 | return $this->callServer("apikeyAdd", $params); 2339 | } 2340 | 2341 | /** 2342 | * Expire a Specific API Key. Note that if you expire all of your keys, just visit your API dashboard 2343 | * to create a new one. If you are trying to shut off access to your account for an old developer, change your 2344 | * MailChimp password, then expire all of the keys they had access to. Note that this takes effect immediately, so make 2345 | * sure you replace the keys in any working application before expiring them! Consider yourself warned... 2346 | * 2347 | * @section Security Related 2348 | * @example mcapi_apikeyExpire.php 2349 | * @example xml-rpc_apikeyExpire.php 2350 | * 2351 | * @param string $username Your MailChimp user name 2352 | * @param string $password Your MailChimp password 2353 | * @return boolean true if it worked, otherwise an error is thrown. 2354 | */ 2355 | function apikeyExpire($username, $password) { 2356 | $params = array(); 2357 | $params["username"] = $username; 2358 | $params["password"] = $password; 2359 | return $this->callServer("apikeyExpire", $params); 2360 | } 2361 | 2362 | /** 2363 | * "Ping" the MailChimp API - a simple method you can call that will return a constant value as long as everything is good. Note 2364 | * than unlike most all of our methods, we don't throw an Exception if we are having issues. You will simply receive a different 2365 | * string back that will explain our view on what is going on. 2366 | * 2367 | * @section Helper 2368 | * @example xml-rpc_ping.php 2369 | * 2370 | * @return string returns "Everything's Chimpy!" if everything is chimpy, otherwise returns an error message 2371 | */ 2372 | function ping() { 2373 | $params = array(); 2374 | return $this->callServer("ping", $params); 2375 | } 2376 | 2377 | /** 2378 | * Internal function - proxy method for certain XML-RPC calls | DO NOT CALL 2379 | * @param mixed Method to call, with any parameters to pass along 2380 | * @return mixed the result of the call 2381 | */ 2382 | function callMethod() { 2383 | $params = array(); 2384 | return $this->callServer("callMethod", $params); 2385 | } 2386 | 2387 | /** 2388 | * Actually connect to the server and call the requested methods, parsing the result 2389 | * You should never have to call this function manually 2390 | */ 2391 | function callServer($method, $params) { 2392 | $dc = "us1"; 2393 | if (strstr($this->api_key,"-")){ 2394 | list($key, $dc) = explode("-",$this->api_key,2); 2395 | if (!$dc) $dc = "us1"; 2396 | } 2397 | $host = $dc.".".$this->apiUrl["host"]; 2398 | $params["apikey"] = $this->api_key; 2399 | 2400 | $this->errorMessage = ""; 2401 | $this->errorCode = ""; 2402 | $sep_changed = false; 2403 | //sigh, apparently some distribs change this to & by default 2404 | if (ini_get("arg_separator.output")!="&"){ 2405 | $sep_changed = true; 2406 | $orig_sep = ini_get("arg_separator.output"); 2407 | ini_set("arg_separator.output", "&"); 2408 | } 2409 | $post_vars = http_build_query($params); 2410 | if ($sep_changed){ 2411 | ini_set("arg_separator.output", $orig_sep); 2412 | } 2413 | 2414 | $payload = "POST " . $this->apiUrl["path"] . "?" . $this->apiUrl["query"] . "&method=" . $method . " HTTP/1.0\r\n"; 2415 | $payload .= "Host: " . $host . "\r\n"; 2416 | $payload .= "User-Agent: MCAPI/" . $this->version ."\r\n"; 2417 | $payload .= "Content-type: application/x-www-form-urlencoded\r\n"; 2418 | $payload .= "Content-length: " . strlen($post_vars) . "\r\n"; 2419 | $payload .= "Connection: close \r\n\r\n"; 2420 | $payload .= $post_vars; 2421 | 2422 | ob_start(); 2423 | if ($this->secure){ 2424 | $sock = fsockopen("ssl://".$host, 443, $errno, $errstr, 30); 2425 | } else { 2426 | $sock = fsockopen($host, 80, $errno, $errstr, 30); 2427 | } 2428 | if(!$sock) { 2429 | $this->errorMessage = "Could not connect (ERR $errno: $errstr)"; 2430 | $this->errorCode = "-99"; 2431 | ob_end_clean(); 2432 | return false; 2433 | } 2434 | 2435 | $response = ""; 2436 | fwrite($sock, $payload); 2437 | stream_set_timeout($sock, $this->timeout); 2438 | $info = stream_get_meta_data($sock); 2439 | while ((!feof($sock)) && (!$info["timed_out"])) { 2440 | $response .= fread($sock, $this->chunkSize); 2441 | $info = stream_get_meta_data($sock); 2442 | } 2443 | fclose($sock); 2444 | ob_end_clean(); 2445 | if ($info["timed_out"]) { 2446 | $this->errorMessage = "Could not read response (timed out)"; 2447 | $this->errorCode = -98; 2448 | return false; 2449 | } 2450 | 2451 | list($headers, $response) = explode("\r\n\r\n", $response, 2); 2452 | $headers = explode("\r\n", $headers); 2453 | $errored = false; 2454 | foreach($headers as $h){ 2455 | if (substr($h,0,26)==="X-MailChimp-API-Error-Code"){ 2456 | $errored = true; 2457 | $error_code = trim(substr($h,27)); 2458 | break; 2459 | } 2460 | } 2461 | 2462 | if(ini_get("magic_quotes_runtime")) $response = stripslashes($response); 2463 | 2464 | $serial = unserialize($response); 2465 | if($response && $serial === false) { 2466 | $response = array("error" => "Bad Response. Got This: " . $response, "code" => "-99"); 2467 | } else { 2468 | $response = $serial; 2469 | } 2470 | if($errored && is_array($response) && isset($response["error"])) { 2471 | $this->errorMessage = $response["error"]; 2472 | $this->errorCode = $response["code"]; 2473 | return false; 2474 | } elseif($errored){ 2475 | $this->errorMessage = "No error message was found"; 2476 | $this->errorCode = $error_code; 2477 | return false; 2478 | } 2479 | 2480 | return $response; 2481 | } 2482 | 2483 | } 2484 | 2485 | ?> --------------------------------------------------------------------------------