PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / 260917
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions v260917
260917 260913 260909 260829 260814 260805 110710 110731 110812 110815 110912 110913 110915 110926 110927 111002 111003 111011 111017 111029 111105 111206 111216 111220 120213 All 189 releases
s2member / src / includes / externals / mailchimp / Mailchimp-o.php

Mailchimp-o.php in s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions 260917, at src/includes/externals/mailchimp/Mailchimp-o.php

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