Easy Forms for MailChimp - Version 1.0.0

Version Description

  • Initial Release

=

Download this release

Release Info

Developer yikesinc
Plugin Icon 128x128 Easy Forms for MailChimp
Version 1.0.0
Comparing to
See all releases

Version 1.0.0

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