Version Description
Download this release
Release Info
Developer | mc_jesse |
Plugin | MailChimp List Subscribe Form |
Version | 0.2 |
Comparing to | |
See all releases |
Version 0.2
- MCAPI.class.php +755 -0
- mailchimp.php +547 -0
- readme.txt +85 -0
- screenshot-1.jpg +0 -0
- screenshot-2.jpg +0 -0
- screenshot-3.jpg +0 -0
- screenshot-4.jpg +0 -0
- screenshot-5.jpg +0 -0
MCAPI.class.php
ADDED
@@ -0,0 +1,755 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class MCAPI {
|
4 |
+
var $version = "1.0";
|
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 id so we only have to log in once per client instantiation
|
25 |
+
*/
|
26 |
+
var $uuid;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Connect to the MailChimp API for a given list. All MCAPI calls require login before functioning
|
30 |
+
*
|
31 |
+
* @param string $username Your MailChimp login user name - always required
|
32 |
+
* @param string $password Your MailChimp login password - always required
|
33 |
+
*/
|
34 |
+
function MCAPI($username, $password) {
|
35 |
+
$this->apiUrl = parse_url("http://api.mailchimp.com/" . $this->version . "/?output=php");
|
36 |
+
$this->uuid = $this->callServer("login", array("username" => $username, "password" => $password));
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Unschedule a campaign that is scheduled to be sent in the future
|
41 |
+
*
|
42 |
+
* @section Campaign Related
|
43 |
+
* @example xml-rpc_campaignUnschedule.php
|
44 |
+
*
|
45 |
+
* @param string $cid the id for the campaign to unschedule
|
46 |
+
* @return boolean true on success
|
47 |
+
*/
|
48 |
+
function campaignUnschedule($cid) {
|
49 |
+
$params = array();
|
50 |
+
$params["cid"] = $cid;
|
51 |
+
return $this->callServer("campaignUnschedule", $params);
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Schedule a campaign to be sent in the future
|
56 |
+
*
|
57 |
+
* @section Campaign Related
|
58 |
+
* @example xml-rpc_campaignSchedule.php
|
59 |
+
*
|
60 |
+
* @param string $cid the id for the campaign to schedule
|
61 |
+
* @param string $schedule_time the time to schedule the campaign - in YYYY-MM-DD HH:II:SS format in GMT
|
62 |
+
* @return boolean true on success
|
63 |
+
*/
|
64 |
+
function campaignSchedule($cid, $schedule_time) {
|
65 |
+
$params = array();
|
66 |
+
$params["cid"] = $cid;
|
67 |
+
$params["schedule_time"] = $schedule_time;
|
68 |
+
return $this->callServer("campaignSchedule", $params);
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Send a given campaign immediately
|
73 |
+
*
|
74 |
+
* @section Campaign Related
|
75 |
+
* @example xml-rpc_campaignSend.php
|
76 |
+
*
|
77 |
+
* @param string $cid the id for the campaign to send
|
78 |
+
* @return boolean true on success
|
79 |
+
*/
|
80 |
+
function campaignSendNow($cid) {
|
81 |
+
$params = array();
|
82 |
+
$params["cid"] = $cid;
|
83 |
+
return $this->callServer("campaignSendNow", $params);
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Send a test of this campaign to the provided email address
|
88 |
+
*
|
89 |
+
* @section Campaign Related
|
90 |
+
* @example xml-rpc_campaignSendTest.php
|
91 |
+
*
|
92 |
+
* @param string $cid the id for the campaign to test
|
93 |
+
* @param string $test_emails an array of email address to receive the test message
|
94 |
+
* @param string $send_type optional default (null) sends both, "html" or "text" send just that format
|
95 |
+
* @return boolean true on success
|
96 |
+
*/
|
97 |
+
function campaignSendTest($cid, $test_emails=array (
|
98 |
+
), $send_type=NULL) {
|
99 |
+
$params = array();
|
100 |
+
$params["cid"] = $cid;
|
101 |
+
$params["test_emails"] = $test_emails;
|
102 |
+
$params["send_type"] = $send_type;
|
103 |
+
return $this->callServer("campaignSendTest", $params);
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Retrieve all templates defined for your user account
|
108 |
+
*
|
109 |
+
* @section Campaign Related
|
110 |
+
* @example xml-rpc_campaignTemplates.php
|
111 |
+
*
|
112 |
+
* @return array An array of structs, one for each template (see Returned Fields for details)
|
113 |
+
* @returnf integer id Id of the template
|
114 |
+
* @returnf string name Name of the template
|
115 |
+
* @returnf string layout Layout of the template - "basic", "left_column", "right_column", or "postcard"
|
116 |
+
* @returnf array sections associative array of editable sections in the template that can accept custom HTML when sending a campaign
|
117 |
+
*/
|
118 |
+
function campaignTemplates() {
|
119 |
+
$params = array();
|
120 |
+
return $this->callServer("campaignTemplates", $params);
|
121 |
+
}
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Create a new draft campaign to send
|
125 |
+
*
|
126 |
+
* @section Campaign Related
|
127 |
+
* @example xml-rpc_createCampaign.php
|
128 |
+
*
|
129 |
+
* @param string $list_id the list to send this campaign to- get lists using getLists()
|
130 |
+
* @param string $subject the subject line for your campaign message
|
131 |
+
* @param string $from_email the From: email address for your campaign message
|
132 |
+
* @param string $from_name the From: name for your campaign message
|
133 |
+
* @param array $content the content for this campaign - use a struct with the following keys: "html" for pasted HTML content and "text" for the plain-text version. 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.
|
134 |
+
* @param integer $template_id optional - use this template to generate the HTML content of the campaign
|
135 |
+
* @param 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.
|
136 |
+
* @param string $title optional - an internal name to use for this campaign. By default, the campaign subject will be used.
|
137 |
+
* @param boolean $authenticate optional - set to true to enable SenderID, DomainKeys, and DKIM authentication, defaults to false
|
138 |
+
* @param string $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
|
139 |
+
* @return string the ID for the created campaign
|
140 |
+
*/
|
141 |
+
function campaignCreate($list_id, $subject, $from_email, $from_name, $content, $template_id=NULL, $tracking=array (
|
142 |
+
'opens' => true,
|
143 |
+
'html_clicks' => true,
|
144 |
+
'text_clicks' => false,
|
145 |
+
), $title=NULL, $authenticate=false, $analytics=NULL) {
|
146 |
+
$params = array();
|
147 |
+
$params["list_id"] = $list_id;
|
148 |
+
$params["subject"] = $subject;
|
149 |
+
$params["from_email"] = $from_email;
|
150 |
+
$params["from_name"] = $from_name;
|
151 |
+
$params["content"] = $content;
|
152 |
+
$params["template_id"] = $template_id;
|
153 |
+
$params["tracking"] = $tracking;
|
154 |
+
$params["title"] = $title;
|
155 |
+
$params["authenticate"] = $authenticate;
|
156 |
+
$params["analytics"] = $analytics;
|
157 |
+
return $this->callServer("campaignCreate", $params);
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Get the list of campaigns and associated information for a list
|
162 |
+
*
|
163 |
+
* @section Campaign Related
|
164 |
+
*
|
165 |
+
* @param string $filter_id optional - only show campaigns from this list id - get lists using getLists()
|
166 |
+
* @param integer $filter_folder optional - only show campaigns from this folder id - get folders using campaignFolders()
|
167 |
+
* @param string $filter_fromname optional - only show campaigns that have this "From Name"
|
168 |
+
* @param string $filter_fromemail optional - only show campaigns that have this "Reply-to Email"
|
169 |
+
* @param string $filter_title optional - only show campaigns that have this title
|
170 |
+
* @param string $filter_subject optional - only show campaigns that have this subject
|
171 |
+
* @param string $filter_sendtimestart optional - only show campaigns that have been sent since this date/time
|
172 |
+
* @param string $filter_sendtimeend optional - only show campaigns that have been sent before this date/time
|
173 |
+
* @param boolean $filter_exact optional - flag for whether to filter on exact values when filtering, or search within content for filter values
|
174 |
+
* @param integer $start optional - control paging of campaigns, start results at this campaign #, defaults to 0 (beginning)
|
175 |
+
* @param integer $limit optional - control paging of campaigns, number of campaigns to return with each call, defaults to 25 (max=5000)
|
176 |
+
* @return array list of campaigns and their associated information (see Returned Fields for description)
|
177 |
+
* @returnf string id Campaign Id (used for all other campaign functions)
|
178 |
+
* @returnf string title Title of the campaign
|
179 |
+
* @returnf date create_time Creation time for the campaign
|
180 |
+
* @returnf date send_time Send time for the campaign
|
181 |
+
* @returnf int emails_sent Number of emails email was sent to
|
182 |
+
* @returnf string status Status of the given campaign (sent,scheduled,etc.)
|
183 |
+
* @returnf string from_name From name of the given campaign
|
184 |
+
* @returnf string from_email Reply-to email of the given campaign
|
185 |
+
* @returnf string subject Subject of the given campaign
|
186 |
+
* @returnf string to_email To email string
|
187 |
+
* @returnf string archive_url Archive link for the given campaign
|
188 |
+
*/
|
189 |
+
function campaigns($filter_id=NULL, $filter_folder=NULL, $filter_fromname=NULL, $filter_fromemail=NULL, $filter_title=NULL, $filter_subject=NULL, $filter_sendtimestart=NULL, $filter_sendtimeend=NULL, $filter_exact=true, $start=0, $limit=25) {
|
190 |
+
$params = array();
|
191 |
+
$params["filter_id"] = $filter_id;
|
192 |
+
$params["filter_folder"] = $filter_folder;
|
193 |
+
$params["filter_fromname"] = $filter_fromname;
|
194 |
+
$params["filter_fromemail"] = $filter_fromemail;
|
195 |
+
$params["filter_title"] = $filter_title;
|
196 |
+
$params["filter_subject"] = $filter_subject;
|
197 |
+
$params["filter_sendtimestart"] = $filter_sendtimestart;
|
198 |
+
$params["filter_sendtimeend"] = $filter_sendtimeend;
|
199 |
+
$params["filter_exact"] = $filter_exact;
|
200 |
+
$params["start"] = $start;
|
201 |
+
$params["limit"] = $limit;
|
202 |
+
return $this->callServer("campaigns", $params);
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* List all the folders for a user account
|
207 |
+
*
|
208 |
+
* @section Campaign Related
|
209 |
+
*
|
210 |
+
* @return array Array of folder structs (see Returned Fields for details)
|
211 |
+
* @returnf integer folder_id Folder Id for the given folder, this can be used in the campaigns() function to filter on.
|
212 |
+
* @returnf string name Name of the given folder
|
213 |
+
*/
|
214 |
+
function campaignFolders() {
|
215 |
+
$params = array();
|
216 |
+
return $this->callServer("campaignFolders", $params);
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Given a list and a campaign, get all the relevant campaign statistics (opens, bounces, clicks, etc.)
|
221 |
+
*
|
222 |
+
* @section Campaign Stats
|
223 |
+
*
|
224 |
+
* @param string $cid the campaign id to pull stats for (can be gathered using campaigns($id))
|
225 |
+
* @return array struct of the statistics for this campaign
|
226 |
+
* @returnf integer syntax_errors Number of email addresses in campaign that had syntactical errors.
|
227 |
+
* @returnf integer hard_bounces Number of email addresses in campaign that hard bounced.
|
228 |
+
* @returnf integer soft_bounces Number of email addresses in campaign that soft bounced.
|
229 |
+
* @returnf integer unsubscribes Number of email addresses in campaign that unsubscribed.
|
230 |
+
* @returnf integer abuse_reports Number of email addresses in campaign that reported campaign for abuse.
|
231 |
+
* @returnf integer forwards Number of times email was forwarded to a friend.
|
232 |
+
* @returnf integer forwards_opens Number of times a forwarded email was opened.
|
233 |
+
* @returnf integer opens Number of times the campaign was opened.
|
234 |
+
* @returnf date last_open Date of the last time the email was opened.
|
235 |
+
* @returnf integer unique_opens Number of people who opened the campaign.
|
236 |
+
* @returnf integer clicks Number of times a link in the campaign was clicked.
|
237 |
+
* @returnf integer unique_clicks Number of unique recipient/click pairs for the campaign.
|
238 |
+
* @returnf date last_click Date of the last time a link in the email was clicked.
|
239 |
+
* @returnf integer users_who_clicked Number of unique recipients who clicked on a link in the campaign.
|
240 |
+
* @returnf integer emails_sent Number of email addresses campaign was sent to.
|
241 |
+
*/
|
242 |
+
function campaignStats($cid) {
|
243 |
+
$params = array();
|
244 |
+
$params["cid"] = $cid;
|
245 |
+
return $this->callServer("campaignStats", $params);
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* Get an array of the urls being tracked, and their click counts for a given campaign
|
250 |
+
*
|
251 |
+
* @section Campaign Stats
|
252 |
+
*
|
253 |
+
* @param string $cid the campaign id to pull stats for (can be gathered using campaigns($id))
|
254 |
+
* @return struct list of urls and their associated statistics
|
255 |
+
* @returnf integer clicks Number of times the specific link was clicked
|
256 |
+
* @returnf integer unique Number of unique people who clicked on the specific link
|
257 |
+
*/
|
258 |
+
function campaignClickStats($cid) {
|
259 |
+
$params = array();
|
260 |
+
$params["cid"] = $cid;
|
261 |
+
return $this->callServer("campaignClickStats", $params);
|
262 |
+
}
|
263 |
+
|
264 |
+
/**
|
265 |
+
* Get all bounced email addresses for a given campaign<br/>
|
266 |
+
* <strong>DEPRECATED:</strong> campaignBounces() has been deprecated and will be removed completely in a future release. see campaignHardBounces() and campaignSoftBounces() for replacements.
|
267 |
+
*
|
268 |
+
* @section Campaign Stats
|
269 |
+
*
|
270 |
+
* @deprecated See campaignHardBounces() and campaignSoftBounces() for replacements
|
271 |
+
* @param string $cid the campaign id to pull bounces for (can be gathered using campaigns($id))
|
272 |
+
* @return struct Struct of arrays of bounced email addresses (hard and soft)
|
273 |
+
* @returnf array hard Array of all email addresses that had Hard bounces for this campaign
|
274 |
+
* @returnf array soft Array of all email addresses that had Soft bounces for this campaign
|
275 |
+
* @returnf array syntax Array of all email addresses that had syntax errors in them (historical - always empty)
|
276 |
+
*/
|
277 |
+
function campaignBounces($cid) {
|
278 |
+
$params = array();
|
279 |
+
$params["cid"] = $cid;
|
280 |
+
return $this->callServer("campaignBounces", $params);
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Get all email addresses with Hard Bounces for a given campaign
|
285 |
+
*
|
286 |
+
* @section Campaign Stats
|
287 |
+
*
|
288 |
+
* @param string $cid the campaign id to pull bounces for (can be gathered using campaigns($id))
|
289 |
+
* @param int $start optional, for large data sets, the page number to start at - defaults to 1st page of data
|
290 |
+
* @param int $limit optional, for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
|
291 |
+
* @return array Arrays of email addresses with Hard Bounces
|
292 |
+
*/
|
293 |
+
function campaignHardBounces($cid, $start=0, $limit=1000) {
|
294 |
+
$params = array();
|
295 |
+
$params["cid"] = $cid;
|
296 |
+
$params["start"] = $start;
|
297 |
+
$params["limit"] = $limit;
|
298 |
+
return $this->callServer("campaignHardBounces", $params);
|
299 |
+
}
|
300 |
+
|
301 |
+
/**
|
302 |
+
* Get all email addresses with Soft Bounces for a given campaign
|
303 |
+
*
|
304 |
+
* @section Campaign Stats
|
305 |
+
*
|
306 |
+
* @param string $cid the campaign id to pull bounces for (can be gathered using campaigns($id))
|
307 |
+
* @param int $start optional, for large data sets, the page number to start at - defaults to 1st page of data
|
308 |
+
* @param int $limit optional, for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
|
309 |
+
* @return array Arrays of email addresses with Soft Bounces
|
310 |
+
*/
|
311 |
+
function campaignSoftBounces($cid, $start=0, $limit=1000) {
|
312 |
+
$params = array();
|
313 |
+
$params["cid"] = $cid;
|
314 |
+
$params["start"] = $start;
|
315 |
+
$params["limit"] = $limit;
|
316 |
+
return $this->callServer("campaignSoftBounces", $params);
|
317 |
+
}
|
318 |
+
|
319 |
+
/**
|
320 |
+
* Get all unsubscribed email addresses for a given campaign
|
321 |
+
*
|
322 |
+
* @section Campaign Stats
|
323 |
+
*
|
324 |
+
* @param string $cid the campaign id to pull bounces for (can be gathered using campaigns($id))
|
325 |
+
* @param int $start optional, for large data sets, the page number to start at - defaults to 1st page of data
|
326 |
+
* @param int $limit optional, for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
|
327 |
+
* @return array list of email addresses that unsubscribed from this campaign
|
328 |
+
*/
|
329 |
+
function campaignUnsubscribes($cid, $start=0, $limit=1000) {
|
330 |
+
$params = array();
|
331 |
+
$params["cid"] = $cid;
|
332 |
+
$params["start"] = $start;
|
333 |
+
$params["limit"] = $limit;
|
334 |
+
return $this->callServer("campaignUnsubscribes", $params);
|
335 |
+
}
|
336 |
+
|
337 |
+
/**
|
338 |
+
* Get all email addresses that complained about a given campaign
|
339 |
+
*
|
340 |
+
* @section Campaign Stats
|
341 |
+
*
|
342 |
+
* @param string $cid the campaign id to pull bounces for (can be gathered using campaigns($id))
|
343 |
+
* @param int $start optional, for large data sets, the page number to start at - defaults to 1st page of data
|
344 |
+
* @param int $limit optional, for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
|
345 |
+
* @return array list of email addresses that complained (filed abuse reports) about this campaign
|
346 |
+
*/
|
347 |
+
function campaignAbuseReports($cid, $start=0, $limit=1000) {
|
348 |
+
$params = array();
|
349 |
+
$params["cid"] = $cid;
|
350 |
+
$params["start"] = $start;
|
351 |
+
$params["limit"] = $limit;
|
352 |
+
return $this->callServer("campaignAbuseReports", $params);
|
353 |
+
}
|
354 |
+
|
355 |
+
/**
|
356 |
+
* Get the content (both html and text) for a campaign, exactly as it would appear in the campaign archive
|
357 |
+
*
|
358 |
+
* @section Campaign Related
|
359 |
+
*
|
360 |
+
* @param string $cid the campaign id to get content for (can be gathered using campaigns($id))
|
361 |
+
* @return struct Struct containing all content for the campaign (see Returned Fields for details
|
362 |
+
* @returnf string html The HTML content used for the campgain with merge tags intact
|
363 |
+
* @returnf string text The Text content used for the campgain with merge tags intact
|
364 |
+
*/
|
365 |
+
function campaignContent($cid) {
|
366 |
+
$params = array();
|
367 |
+
$params["cid"] = $cid;
|
368 |
+
return $this->callServer("campaignContent", $params);
|
369 |
+
}
|
370 |
+
|
371 |
+
/**
|
372 |
+
* Retrieve the list of email addresses that opened a given campaign with how many times they opened
|
373 |
+
*
|
374 |
+
* @section Campaign AIM
|
375 |
+
*
|
376 |
+
* @param string $cid the campaign id to get opens for (can be gathered using campaigns($id))
|
377 |
+
* @param int $start optional, for large data sets, the page number to start at - defaults to 1st page of data
|
378 |
+
* @param int $limit optional, for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
|
379 |
+
* @return array Array of structs containing email addresses and open counts
|
380 |
+
* @returnf string email Email address that opened the campaign
|
381 |
+
* @returnf integer open_count Total number of times the campaign was opened by this email address
|
382 |
+
*/
|
383 |
+
function campaignOpenedAIM($cid, $start=0, $limit=1000) {
|
384 |
+
$params = array();
|
385 |
+
$params["cid"] = $cid;
|
386 |
+
$params["start"] = $start;
|
387 |
+
$params["limit"] = $limit;
|
388 |
+
return $this->callServer("campaignOpenedAIM", $params);
|
389 |
+
}
|
390 |
+
|
391 |
+
/**
|
392 |
+
* Retrieve the list of email addresses that did not open a given campaign
|
393 |
+
*
|
394 |
+
* @section Campaign AIM
|
395 |
+
*
|
396 |
+
* @param string $cid the campaign id to get no opens for (can be gathered using campaigns($id))
|
397 |
+
* @param int $start optional, for large data sets, the page number to start at - defaults to 1st page of data
|
398 |
+
* @param int $limit optional, for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
|
399 |
+
* @return array list of email addresses that did not open a campaign
|
400 |
+
*/
|
401 |
+
function campaignNotOpenedAIM($cid, $start=0, $limit=1000) {
|
402 |
+
$params = array();
|
403 |
+
$params["cid"] = $cid;
|
404 |
+
$params["start"] = $start;
|
405 |
+
$params["limit"] = $limit;
|
406 |
+
return $this->callServer("campaignNotOpenedAIM", $params);
|
407 |
+
}
|
408 |
+
|
409 |
+
/**
|
410 |
+
* Return the list of email addresses that clicked on a given url, and how many times they clicked
|
411 |
+
*
|
412 |
+
* @section Campaign AIM
|
413 |
+
*
|
414 |
+
* @param string $cid the campaign id to get click stats for (can be gathered using campaigns($id))
|
415 |
+
* @param string $url the URL of the link that was clicked on
|
416 |
+
* @param int $start optional, for large data sets, the page number to start at - defaults to 1st page of data
|
417 |
+
* @param int $limit optional, for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
|
418 |
+
* @return array Array of structs containing email addresses and click counts
|
419 |
+
* @returnf string email Email address that opened the campaign
|
420 |
+
* @returnf integer clicks Total number of times the URL was clicked on by this email address
|
421 |
+
*/
|
422 |
+
function campaignClickDetailAIM($cid, $url, $start=0, $limit=1000) {
|
423 |
+
$params = array();
|
424 |
+
$params["cid"] = $cid;
|
425 |
+
$params["url"] = $url;
|
426 |
+
$params["start"] = $start;
|
427 |
+
$params["limit"] = $limit;
|
428 |
+
return $this->callServer("campaignClickDetailAIM", $params);
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Given a campaign and email address, return the entire click and open history with timestamps, ordered by time
|
433 |
+
*
|
434 |
+
* @section Campaign AIM
|
435 |
+
*
|
436 |
+
* @param string $cid the campaign id to get stats for (can be gathered using campaigns($id))
|
437 |
+
* @param string $email_address the email address to get activity history for
|
438 |
+
* @return array Array of structs containing actions (opens and clicks) that the email took, with timestamps
|
439 |
+
* @returnf string action The action taken (open or click)
|
440 |
+
* @returnf date timestamp Time the action occurred
|
441 |
+
* @returnf string url For clicks, the URL that was clicked
|
442 |
+
*/
|
443 |
+
function campaignEmailStatsAIM($cid, $email_address) {
|
444 |
+
$params = array();
|
445 |
+
$params["cid"] = $cid;
|
446 |
+
$params["email_address"] = $email_address;
|
447 |
+
return $this->callServer("campaignEmailStatsAIM", $params);
|
448 |
+
}
|
449 |
+
|
450 |
+
/**
|
451 |
+
* Retrieve all of the lists defined for your user account
|
452 |
+
*
|
453 |
+
* @section List Related
|
454 |
+
* @example xml-rpc_lists.php
|
455 |
+
*
|
456 |
+
* @return array list of your Lists and their associated information (see Returned Fields for description)
|
457 |
+
* @returnf string id The list id for this list. This will be used for all other list management functions.
|
458 |
+
* @returnf string name The name of the list.
|
459 |
+
* @returnf date date_created The date that this list was created.
|
460 |
+
* @returnf integer member_count The number of active members in the given list.
|
461 |
+
*/
|
462 |
+
function lists() {
|
463 |
+
$params = array();
|
464 |
+
return $this->callServer("lists", $params);
|
465 |
+
}
|
466 |
+
|
467 |
+
/**
|
468 |
+
* Get the list of merge tags for a given list, including their name, tag, and required setting
|
469 |
+
*
|
470 |
+
* @section List Related
|
471 |
+
*
|
472 |
+
* @param string $id the list id to connect to
|
473 |
+
* @return array list of merge tags for the list
|
474 |
+
* @returnf string name Name of the merge field
|
475 |
+
* @returnf char req Denotes whether the field is required (Y) or not (N)
|
476 |
+
* @returnf string tag The merge tag that's used for forms and listSubscribe() and listUpdateMember()
|
477 |
+
*/
|
478 |
+
function listMergeVars($id) {
|
479 |
+
$params = array();
|
480 |
+
$params["id"] = $id;
|
481 |
+
return $this->callServer("listMergeVars", $params);
|
482 |
+
}
|
483 |
+
|
484 |
+
/**
|
485 |
+
* Get the list of interest groups for a given list, including the label and form information
|
486 |
+
*
|
487 |
+
* @section List Related
|
488 |
+
*
|
489 |
+
* @param string $id the list id to connect to
|
490 |
+
* @return struct list of interest groups for the list
|
491 |
+
* @returnf string name Name for the Interest groups
|
492 |
+
* @returnf string form_field Gives the type of interest group: checkbox,radio,select
|
493 |
+
* @returnf array groups Array of the group names
|
494 |
+
*/
|
495 |
+
function listInterestGroups($id) {
|
496 |
+
$params = array();
|
497 |
+
$params["id"] = $id;
|
498 |
+
return $this->callServer("listInterestGroups", $params);
|
499 |
+
}
|
500 |
+
|
501 |
+
/**
|
502 |
+
* Subscribe the provided email to a list
|
503 |
+
*
|
504 |
+
* @section List Related
|
505 |
+
*
|
506 |
+
* @example mcapi_listSubscribe.php
|
507 |
+
* @example xml-rpc_listSubscribe.php
|
508 |
+
*
|
509 |
+
* @param string $id the list id to connect to
|
510 |
+
* @param string $email_address the email address to subscribe
|
511 |
+
* @param array $merge_vars array of merges for the email (FNAME, LNAME, etc.) (see examples below for handling "blank" arrays)
|
512 |
+
* @param string $email_type optional - email type preference for the email (html or text, defaults to html)
|
513 |
+
* @param boolean $double_optin optional - flag to control whether a double opt-in confirmation message is sent, defaults to true
|
514 |
+
* @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)
|
515 |
+
*/
|
516 |
+
function listSubscribe($id, $email_address, $merge_vars, $email_type='html', $double_optin=true) {
|
517 |
+
$params = array();
|
518 |
+
$params["id"] = $id;
|
519 |
+
$params["email_address"] = $email_address;
|
520 |
+
$params["merge_vars"] = $merge_vars;
|
521 |
+
$params["email_type"] = $email_type;
|
522 |
+
$params["double_optin"] = $double_optin;
|
523 |
+
return $this->callServer("listSubscribe", $params);
|
524 |
+
}
|
525 |
+
|
526 |
+
/**
|
527 |
+
* Unsubscribe the given email address from the list
|
528 |
+
*
|
529 |
+
* @section List Related
|
530 |
+
* @example mcapi_listUnsubscribe.php
|
531 |
+
*
|
532 |
+
* @param string $id the list id to connect to
|
533 |
+
* @param string $email_address the email address to unsubscribe
|
534 |
+
* @param boolean $delete_member flag to completely delete the member from your list instead of just unsubscribing, default to false
|
535 |
+
* @param boolean $send_goodbye flag to send the goodbye email to the email address, defaults to true
|
536 |
+
* @param boolean $send_notify flag to send the unsubscribe notification email to the address defined in the list email notification settings, defaults to true
|
537 |
+
* @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)
|
538 |
+
*/
|
539 |
+
function listUnsubscribe($id, $email_address, $delete_member=false, $send_goodbye=true, $send_notify=true) {
|
540 |
+
$params = array();
|
541 |
+
$params["id"] = $id;
|
542 |
+
$params["email_address"] = $email_address;
|
543 |
+
$params["delete_member"] = $delete_member;
|
544 |
+
$params["send_goodbye"] = $send_goodbye;
|
545 |
+
$params["send_notify"] = $send_notify;
|
546 |
+
return $this->callServer("listUnsubscribe", $params);
|
547 |
+
}
|
548 |
+
|
549 |
+
/**
|
550 |
+
* Edit the email address, merge fields, and interest groups for a list member
|
551 |
+
*
|
552 |
+
* @section List Related
|
553 |
+
*
|
554 |
+
* @param string $id the list id to connect to
|
555 |
+
* @param string $email_address the current email address of the member to update
|
556 |
+
* @param array $merge_vars array of new field values to update the member with. Use "EMAIL" to update the email address and "INTERESTS" to update the interest groups
|
557 |
+
* @param string $email_type change the email type preference for the member ("html" or "text"). Leave blank to keep the existing preference (optional)
|
558 |
+
* @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)
|
559 |
+
* @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
|
560 |
+
*/
|
561 |
+
function listUpdateMember($id, $email_address, $merge_vars, $email_type='', $replace_interests=true) {
|
562 |
+
$params = array();
|
563 |
+
$params["id"] = $id;
|
564 |
+
$params["email_address"] = $email_address;
|
565 |
+
$params["merge_vars"] = $merge_vars;
|
566 |
+
$params["email_type"] = $email_type;
|
567 |
+
$params["replace_interests"] = $replace_interests;
|
568 |
+
return $this->callServer("listUpdateMember", $params);
|
569 |
+
}
|
570 |
+
|
571 |
+
/**
|
572 |
+
* Subscribe a batch of email addresses to a list at once
|
573 |
+
*
|
574 |
+
* @section List Related
|
575 |
+
* @example xml-rpc_listBatchSubscribe.php
|
576 |
+
*
|
577 |
+
* @param string $id the list id to connect to
|
578 |
+
* @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 or text)
|
579 |
+
* @param boolean $double_optin flag to control whether to send an opt-in confirmation email - defaults to true
|
580 |
+
* @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)
|
581 |
+
* @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)
|
582 |
+
* @return struct Array of result counts and any errors that occurred
|
583 |
+
* @returnf integer success_count Number of email addresses that were succesfully added/updated
|
584 |
+
* @returnf integer error_count Number of email addresses that failed during addition/updating
|
585 |
+
* @returnf array errors Array of error structs. Each error struct will contain "code", "message", and "email_address"
|
586 |
+
*/
|
587 |
+
function listBatchSubscribe($id, $batch, $double_optin=true, $update_existing=false, $replace_interests=true) {
|
588 |
+
$params = array();
|
589 |
+
$params["id"] = $id;
|
590 |
+
$params["batch"] = $batch;
|
591 |
+
$params["double_optin"] = $double_optin;
|
592 |
+
$params["update_existing"] = $update_existing;
|
593 |
+
$params["replace_interests"] = $replace_interests;
|
594 |
+
return $this->callServer("listBatchSubscribe", $params);
|
595 |
+
}
|
596 |
+
|
597 |
+
/**
|
598 |
+
* Unsubscribe a batch of email addresses to a list
|
599 |
+
*
|
600 |
+
* @section List Related
|
601 |
+
*
|
602 |
+
* @param string $id the list id to connect to
|
603 |
+
* @param array $emails array of email addresses to unsubscribe
|
604 |
+
* @param boolean $delete_member flag to completely delete the member from your list instead of just unsubscribing, default to false
|
605 |
+
* @param boolean $send_goodbye flag to send the goodbye email to the email addresses, defaults to true
|
606 |
+
* @param boolean $send_notify flag to send the unsubscribe notification email to the address defined in the list email notification settings, defaults to false
|
607 |
+
* @return struct Array of result counts and any errors that occurred
|
608 |
+
* @returnf integer success_count Number of email addresses that were succesfully added/updated
|
609 |
+
* @returnf integer error_count Number of email addresses that failed during addition/updating
|
610 |
+
* @returnf array errors Array of error structs. Each error struct will contain "code", "message", and "email_address"
|
611 |
+
*/
|
612 |
+
function listBatchUnsubscribe($id, $emails, $delete_member=false, $send_goodbye=true, $send_notify=false) {
|
613 |
+
$params = array();
|
614 |
+
$params["id"] = $id;
|
615 |
+
$params["emails"] = $emails;
|
616 |
+
$params["delete_member"] = $delete_member;
|
617 |
+
$params["send_goodbye"] = $send_goodbye;
|
618 |
+
$params["send_notify"] = $send_notify;
|
619 |
+
return $this->callServer("listBatchUnsubscribe", $params);
|
620 |
+
}
|
621 |
+
|
622 |
+
/**
|
623 |
+
* Get all of the list members of a list that are of a particular status
|
624 |
+
*
|
625 |
+
* @section List Related
|
626 |
+
* @example mcapi_listMembers.php
|
627 |
+
*
|
628 |
+
* @param string $id the list id to connect to
|
629 |
+
* @param string $status the status to get members for - one of(subscribed, unsubscribed, or cleaned), defaults to subscribed
|
630 |
+
* @param int $start optional, for large data sets, the page number to start at - defaults to 1st page of data
|
631 |
+
* @param int $limit optional, for large data sets, the number of results to return - defaults to 100, upper limit set at 15000
|
632 |
+
* @return array Array of list member structs (see Returned Fields for details)
|
633 |
+
* @returnf string email Member email address
|
634 |
+
* @returnf date timestamp timestamp of their associated status(date subscribed, unsubscribed, or cleaned)
|
635 |
+
*/
|
636 |
+
function listMembers($id, $status='subscribed', $start=0, $limit=100) {
|
637 |
+
$params = array();
|
638 |
+
$params["id"] = $id;
|
639 |
+
$params["status"] = $status;
|
640 |
+
$params["start"] = $start;
|
641 |
+
$params["limit"] = $limit;
|
642 |
+
return $this->callServer("listMembers", $params);
|
643 |
+
}
|
644 |
+
|
645 |
+
/**
|
646 |
+
* Get all the information for a particular member of a list
|
647 |
+
*
|
648 |
+
* @section List Related
|
649 |
+
* @example mcapi_listMemberInfo.php
|
650 |
+
* @param string $id the list id to connect to
|
651 |
+
* @param string $email_address the member email address to get information for
|
652 |
+
* @return array array of list member info (see Returned Fields for details)
|
653 |
+
* @returnf string email The email address associated with this record
|
654 |
+
* @returnf string email_type The type of emails this customer asked to get: html or text
|
655 |
+
* @returnf array merges An associative array of all the merge tags and the data for those tags for this email address
|
656 |
+
* @returnf string status The subscription status for this email address, either subscribed, unsubscribed or cleaned
|
657 |
+
* @returnf date timestamp The time this email address was added to the list
|
658 |
+
*/
|
659 |
+
function listMemberInfo($id, $email_address) {
|
660 |
+
$params = array();
|
661 |
+
$params["id"] = $id;
|
662 |
+
$params["email_address"] = $email_address;
|
663 |
+
return $this->callServer("listMemberInfo", $params);
|
664 |
+
}
|
665 |
+
|
666 |
+
/**
|
667 |
+
* Internal function - proxy method for certain XML-RPC calls | DO NOT CALL
|
668 |
+
* @param mixed Method to call, with any parameters to pass along
|
669 |
+
* @return mixed the result of the call
|
670 |
+
*/
|
671 |
+
function callMethod() {
|
672 |
+
$params = array();
|
673 |
+
return $this->callServer("callMethod", $params);
|
674 |
+
}
|
675 |
+
|
676 |
+
/**
|
677 |
+
* Actually connect to the server and call the requested methods, parsing the result
|
678 |
+
* You should never have to call this function manually
|
679 |
+
*/
|
680 |
+
function callServer($method, $params) {
|
681 |
+
//Always include the user id if we're not loggin in
|
682 |
+
if($method != "login") {
|
683 |
+
$params["uid"] = $this->uuid;
|
684 |
+
}
|
685 |
+
|
686 |
+
$post_vars = $this->httpBuildQuery($params);
|
687 |
+
|
688 |
+
$payload = "POST " . $this->apiUrl["path"] . "?" . $this->apiUrl["query"] . "&method=" . $method . " HTTP/1.0\r\n";
|
689 |
+
$payload .= "Host: " . $this->apiUrl["host"] . "\r\n";
|
690 |
+
$payload .= "User-Agent: MCAPI-Wordpress/".$this->version."\r\n";
|
691 |
+
$payload .= "Content-type: application/x-www-form-urlencoded\r\n";
|
692 |
+
$payload .= "Content-length: " . strlen($post_vars) . "\r\n";
|
693 |
+
$payload .= "Connection: close \r\n\r\n";
|
694 |
+
$payload .= $post_vars;
|
695 |
+
|
696 |
+
ob_start();
|
697 |
+
$sock = fsockopen($this->apiUrl["host"], 80, $errno, $errstr, $this->timeout);
|
698 |
+
if(!$sock) {
|
699 |
+
$this->errorMessage = "Could not connect (ERR $errno: $errstr)";
|
700 |
+
$this->errorCode = "SERVER_ERROR";
|
701 |
+
ob_end_clean();
|
702 |
+
return false;
|
703 |
+
}
|
704 |
+
|
705 |
+
$response = "";
|
706 |
+
fwrite($sock, $payload);
|
707 |
+
while(!feof($sock)) {
|
708 |
+
$response .= fread($sock, $this->chunkSize);
|
709 |
+
}
|
710 |
+
fclose($sock);
|
711 |
+
ob_end_clean();
|
712 |
+
|
713 |
+
list($throw, $response) = explode("\r\n\r\n", $response, 2);
|
714 |
+
|
715 |
+
if(ini_get("magic_quotes_runtime")) $response = stripslashes($response);
|
716 |
+
|
717 |
+
$serial = unserialize($response);
|
718 |
+
if($response && $serial === false) {
|
719 |
+
$response = array("error" => "Bad Response. Got This: " . $response, "code" => "SERVER_ERROR");
|
720 |
+
} else {
|
721 |
+
$response = $serial;
|
722 |
+
}
|
723 |
+
if(is_array($response) && isset($response["error"])) {
|
724 |
+
$this->errorMessage = $response["error"];
|
725 |
+
$this->errorCode = $response["code"];
|
726 |
+
return false;
|
727 |
+
}
|
728 |
+
|
729 |
+
return $response;
|
730 |
+
}
|
731 |
+
|
732 |
+
/**
|
733 |
+
* Re-implement http_build_query for systems that do not already have it
|
734 |
+
*/
|
735 |
+
function httpBuildQuery($params, $key=null) {
|
736 |
+
$ret = array();
|
737 |
+
|
738 |
+
foreach((array) $params as $name => $val) {
|
739 |
+
$name = urlencode($name);
|
740 |
+
if($key !== null) {
|
741 |
+
$name = $key . "[" . $name . "]";
|
742 |
+
}
|
743 |
+
|
744 |
+
if(is_array($val) || is_object($val)) {
|
745 |
+
$ret[] = $this->httpBuildQuery($val, $name);
|
746 |
+
} elseif($val !== null) {
|
747 |
+
$ret[] = $name . "=" . urlencode($val);
|
748 |
+
}
|
749 |
+
}
|
750 |
+
|
751 |
+
return implode("&", $ret);
|
752 |
+
}
|
753 |
+
}
|
754 |
+
|
755 |
+
?>
|
mailchimp.php
ADDED
@@ -0,0 +1,547 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: MailChimp
|
4 |
+
Plugin URI: http://mailchimp.com/api/plugins/wordpress
|
5 |
+
Description: The MailChimp plugin allows you to easily setup a Subscribe box for your MailChimp list - So easy a chimp could do it!
|
6 |
+
Version: 0.2
|
7 |
+
Author: MailChimp API Support Team
|
8 |
+
Author URI: http://mailchimp.com/api/
|
9 |
+
*/
|
10 |
+
|
11 |
+
/* Copyright 2008 MailChimp.com (email : api@mailchimp.com)
|
12 |
+
|
13 |
+
This program is free software; you can redistribute it and/or modify
|
14 |
+
it under the terms of the GNU General Public License as published by
|
15 |
+
the Free Software Foundation; either version 2 of the License, or
|
16 |
+
(at your option) any later version.
|
17 |
+
|
18 |
+
This program is distributed in the hope that it will be useful,
|
19 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21 |
+
GNU General Public License for more details.
|
22 |
+
|
23 |
+
You should have received a copy of the GNU General Public License
|
24 |
+
along with this program; if not, write to the Free Software
|
25 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
26 |
+
*/
|
27 |
+
include_once('MCAPI.class.php');
|
28 |
+
|
29 |
+
// some custom CSS//
|
30 |
+
function mc_admin_css() {
|
31 |
+
echo "
|
32 |
+
<style type='text/css'>
|
33 |
+
.error_msg {
|
34 |
+
color: red;
|
35 |
+
}
|
36 |
+
.success_msg {
|
37 |
+
color: green;
|
38 |
+
}
|
39 |
+
}
|
40 |
+
</style>
|
41 |
+
";
|
42 |
+
}
|
43 |
+
function mc_main_css() {
|
44 |
+
echo "
|
45 |
+
<style type='text/css'>
|
46 |
+
.error_msg {
|
47 |
+
color: red;
|
48 |
+
}
|
49 |
+
.success_msg {
|
50 |
+
color: green;
|
51 |
+
}
|
52 |
+
.mc_custom_border{ padding:5px; ";
|
53 |
+
if (get_option('mc_custom_style')=='on'){
|
54 |
+
echo "border-width: ".get_option('mc_form_border_width').'px;';
|
55 |
+
echo "border-style: solid;";
|
56 |
+
echo "border-color: #".get_option('mc_form_border_color').';';
|
57 |
+
echo "color: #".get_option('mc_form_text_color').';';
|
58 |
+
echo "background-color: #".get_option('mc_form_background').';';
|
59 |
+
}
|
60 |
+
echo "
|
61 |
+
}
|
62 |
+
</style>
|
63 |
+
";
|
64 |
+
}//mc_main_css
|
65 |
+
|
66 |
+
add_action('admin_head', 'mc_admin_css');
|
67 |
+
add_action('wp_head', 'mc_main_css');
|
68 |
+
|
69 |
+
// Hook for adding admin menus
|
70 |
+
add_action('admin_menu', 'mc_add_pages');
|
71 |
+
|
72 |
+
// action function for above hook
|
73 |
+
function mc_add_pages() {
|
74 |
+
|
75 |
+
//7 is lowest w/ Plugin Editing capability
|
76 |
+
add_options_page('MailChimp Setup', 'MailChimp Setup', 7, 'mc_setup_page', 'mc_setup_page');
|
77 |
+
}
|
78 |
+
|
79 |
+
function mc_setup_page(){
|
80 |
+
?>
|
81 |
+
<div class="wrap">
|
82 |
+
<h2>MailChimp List Setup</h2>
|
83 |
+
<?php
|
84 |
+
//see if we need to set/change the username & password.
|
85 |
+
if (isset($_REQUEST['mc_username']) && isset($_REQUEST['mc_username'])){
|
86 |
+
if ($_REQUEST['mc_username']!=get_option('mc_username') || $_REQUEST['mc_password']!=get_option('mc_password')){
|
87 |
+
$delete_setup = false;
|
88 |
+
$api = new MCAPI($_REQUEST['mc_username'], $_REQUEST['mc_password']);
|
89 |
+
if ($api->errorCode == ''){
|
90 |
+
$msg = "<span class='success_msg'>Success! We were able to verify your username & password! Let's continue, shall we?</span>";
|
91 |
+
update_option('mc_username', $_REQUEST['mc_username']);
|
92 |
+
update_option('mc_password', $_REQUEST['mc_password']);
|
93 |
+
update_option('mc_user_id', $api->uuid);
|
94 |
+
if (get_option('mc_list_id')!=''){
|
95 |
+
$lists = $api->lists();
|
96 |
+
$delete_setup = true;
|
97 |
+
//but don't delete if the list still exists...
|
98 |
+
foreach($lists as $list){ if ($list['id']==get_option('mc_list_id')){ $list_id = $_REQUEST['mc_list_id']; $delete_setup=false; } }
|
99 |
+
}
|
100 |
+
} else {
|
101 |
+
$msg = "<span class='error_msg'>Uh-oh, we were unable to login and verify your username & password. Please check them and try again!<br/>";
|
102 |
+
$msg .= "The server said: <i>".$api->errorMessage."</i></span>";
|
103 |
+
if (get_option('mc_username')==''){
|
104 |
+
$delete_setup = true;
|
105 |
+
}
|
106 |
+
}
|
107 |
+
if ($delete_setup){
|
108 |
+
delete_option('mc_user_id');
|
109 |
+
delete_option('mc_username');
|
110 |
+
delete_option('mc_password');
|
111 |
+
delete_option('mc_rewards');
|
112 |
+
delete_option('mc_list_id');
|
113 |
+
delete_option('mc_list_name');
|
114 |
+
delete_option('mc_interest_groups');
|
115 |
+
delete_option('mc_show_interest_groups');
|
116 |
+
$mv = unserialize(get_option('mc_merge_vars'));
|
117 |
+
foreach($mv as $var){
|
118 |
+
$opt = 'mc_mv_'.$var['tag'];
|
119 |
+
delete_option($opt);
|
120 |
+
}
|
121 |
+
delete_option('mc_merge_vars');
|
122 |
+
}
|
123 |
+
}
|
124 |
+
if (isset($_REQUEST['mc_rewards']) && $_REQUEST['mc_rewards'] != get_option('mc_rewards')){
|
125 |
+
update_option('mc_rewards', 'on');
|
126 |
+
if ($msg) $msg .= '<br/>';
|
127 |
+
$msg .= '<span class="success_msg">Monkey Rewards turned On!</span>';
|
128 |
+
} else if (get_option('mc_rewards')!='off') {
|
129 |
+
update_option('mc_rewards', 'off');
|
130 |
+
if ($msg) $msg .= '<br/>';
|
131 |
+
$msg .= '<span class="success_msg">Monkey Rewards turned Off!</span>';
|
132 |
+
}
|
133 |
+
//set these for the form fields below
|
134 |
+
$user = $_REQUEST['mc_username'];
|
135 |
+
$pass = $_REQUEST['mc_password'];
|
136 |
+
} else {
|
137 |
+
$user = get_option('mc_username');
|
138 |
+
$pass = get_option('mc_password');
|
139 |
+
}
|
140 |
+
if (isset($_REQUEST['mc_list_id'])){
|
141 |
+
$api = new MCAPI(get_option('mc_username'), get_option('mc_password'));
|
142 |
+
$lists = $api->lists();
|
143 |
+
foreach($lists as $list){ if ($list['id']==$_REQUEST['mc_list_id']){ $list_id = $_REQUEST['mc_list_id']; $list_name = $list['name']; } }
|
144 |
+
if ($list_id == ''){
|
145 |
+
$msg = '<span class="error_msg">Uh-oh, something went wrong while trying to load List with ID: '.$_REQUEST['mc_list_id'].'</span>';
|
146 |
+
|
147 |
+
} else {
|
148 |
+
update_option('mc_list_id', $list_id);
|
149 |
+
update_option('mc_list_name', $list_name);
|
150 |
+
|
151 |
+
update_option('mc_header_content','<h2>Sign up for '.$list_name.'</h2>');
|
152 |
+
update_option('mc_submit_text','Subscribe');
|
153 |
+
|
154 |
+
update_option('mc_custom_style','on');
|
155 |
+
update_option('mc_form_border_width','1');
|
156 |
+
update_option('mc_form_border_color','ccc');
|
157 |
+
update_option('mc_form_background','ffffcc');
|
158 |
+
update_option('mc_form_text_color','666666');
|
159 |
+
|
160 |
+
$mv = $api->listMergeVars($list_id);
|
161 |
+
$ig = $api->listInterestGroups($list_id);
|
162 |
+
update_option('mc_merge_vars', serialize( $mv ) );
|
163 |
+
foreach($mv as $var){
|
164 |
+
$opt = 'mc_mv_'.$var['tag'];
|
165 |
+
//turn them all on by default
|
166 |
+
update_option($opt, 'on' );
|
167 |
+
}
|
168 |
+
update_option('mc_interest_groups', serialize( $ig ) );
|
169 |
+
update_option('mc_show_interest_groups', 'on' );
|
170 |
+
$msg = '<span class="success_msg">Success! Loaded and saved the info for '.sizeof($mv).' Merge Variables and '.
|
171 |
+
sizeof($ig).' Interest Groups from your list "'.$list['name'].'"<br/><br/>
|
172 |
+
Now you should either Turn On the MailChimp Widget or change your options below, then turn it on.</span>';
|
173 |
+
}
|
174 |
+
|
175 |
+
}
|
176 |
+
if (isset($_REQUEST['reset_list'])){
|
177 |
+
delete_option('mc_list_id');
|
178 |
+
delete_option('mc_list_name');
|
179 |
+
delete_option('mc_merge_vars');
|
180 |
+
delete_option('mc_interest_groups');
|
181 |
+
|
182 |
+
delete_option('mc_header_content');
|
183 |
+
delete_option('mc_submit_text');
|
184 |
+
|
185 |
+
delete_option('mc_custom_style');
|
186 |
+
delete_option('mc_form_border_width');
|
187 |
+
delete_option('mc_form_border_color');
|
188 |
+
delete_option('mc_form_background');
|
189 |
+
delete_option('mc_form_text_color');
|
190 |
+
|
191 |
+
$msg = '<span class="success_msg">Successfully Reset your List selection... Now you get to pick again!</span>';
|
192 |
+
}
|
193 |
+
if (isset($_REQUEST['change_form_settings'])){
|
194 |
+
$content = stripslashes($_REQUEST['mc_header_content']);
|
195 |
+
$content = str_replace("\r\n","<br/>", $content);
|
196 |
+
update_option('mc_header_content', $content );
|
197 |
+
|
198 |
+
$submit_text = stripslashes($_REQUEST['mc_submit_text']);
|
199 |
+
$submit_text = str_replace("\r\n","", $submit_text);
|
200 |
+
update_option('mc_submit_text', $submit_text);
|
201 |
+
|
202 |
+
if (isset($_REQUEST['mc_custom_style'])){
|
203 |
+
update_option('mc_custom_style','on');
|
204 |
+
} else {
|
205 |
+
update_option('mc_custom_style','off');
|
206 |
+
}
|
207 |
+
|
208 |
+
//we told them not to put these things we are replacing in, but let's just make sure they are listening...
|
209 |
+
update_option('mc_form_border_width',str_replace('px','',$_REQUEST['mc_form_border_width']) );
|
210 |
+
update_option('mc_form_border_color', str_replace('#','',$_REQUEST['mc_form_border_color']));
|
211 |
+
update_option('mc_form_background',str_replace('#','',$_REQUEST['mc_form_background']));
|
212 |
+
update_option('mc_form_text_color', str_replace('#','',$_REQUEST['mc_form_text_color']));
|
213 |
+
|
214 |
+
if (isset($_REQUEST['mc_show_interest_groups'])){
|
215 |
+
update_option('mc_show_interest_groups','on');
|
216 |
+
} else {
|
217 |
+
update_option('mc_show_interest_groups','off');
|
218 |
+
}
|
219 |
+
$mv = unserialize(get_option('mc_merge_vars'));
|
220 |
+
foreach($mv as $var){
|
221 |
+
$opt = 'mc_mv_'.$var['tag'];
|
222 |
+
if (isset($_REQUEST[$opt]) || $var['req']=='Y'){
|
223 |
+
update_option($opt,'on');
|
224 |
+
} else {
|
225 |
+
update_option($opt,'off');
|
226 |
+
}
|
227 |
+
}
|
228 |
+
$msg = '<span class="success_msg">Successfully Updated your List Subscribe Form Settings!</span>';
|
229 |
+
|
230 |
+
}
|
231 |
+
if ($msg){
|
232 |
+
echo '<div id="message" class="updated fade"><p><strong>'.$msg.'</strong></p></div>';
|
233 |
+
}
|
234 |
+
?>
|
235 |
+
<form method="post" action="options-general.php?page=mc_setup_page">
|
236 |
+
<?php wp_nonce_field('update-options'); ?>
|
237 |
+
<h3>Login Info</h3>
|
238 |
+
To start using the MailChimp plugin, we first need to store your MailChimp Username & Password<br/>
|
239 |
+
<table class="form-table">
|
240 |
+
<tr valign="top">
|
241 |
+
<th scope="row">Username:</th>
|
242 |
+
<td><input name="mc_username" type="text" id="mc_username" class="code" value="<?php echo $user; ?>" size="20" /></td>
|
243 |
+
</tr>
|
244 |
+
<tr valign="top">
|
245 |
+
<th scope="row">Password:</th>
|
246 |
+
<td><input name="mc_password" type="text" id="mc_password" class="code" value="<?php echo $pass; ?>" size="20" /></td>
|
247 |
+
</tr>
|
248 |
+
<tr valign="top">
|
249 |
+
<th scope="row">Monkey Rewards:</th>
|
250 |
+
<td><input name="mc_rewards" type="checkbox" <?php if (get_option('mc_rewards')=='on' || get_option('mc_rewards')=='' ) {echo 'checked';} ?> id="mc_rewards" class="code" />
|
251 |
+
<i>turning this on will place a "powered by MailChimp" link in your form that will earn you credits with us. It is optional and can be turned on or off at any time.</i>
|
252 |
+
</td>
|
253 |
+
</tr>
|
254 |
+
</table>
|
255 |
+
|
256 |
+
<p class="submit">
|
257 |
+
<input type="hidden" name="action" value="update"/>
|
258 |
+
<input type="hidden" name="page_options" value="mc_username,mc_password" />
|
259 |
+
<input type="submit" name="Submit" value="Save & Check" class="button" />
|
260 |
+
<?php
|
261 |
+
if (get_option('mc_username')!=''){
|
262 |
+
echo '<strong>Notes:</strong><ul>
|
263 |
+
<li><i>Changing your settings at MailChimp.com may cause this to stop working.</i></li>
|
264 |
+
<li><i>Changing your username & password at MailChimp.com will cause this plugin to stop working!</i></li>
|
265 |
+
<li><i>If you change your login to a different account, the info you have setup below will be erased.</i></li>
|
266 |
+
<li><i>If any of that happens, no biggie - just reconfigure your login and the items below...</i></li></ul>
|
267 |
+
<br/>';
|
268 |
+
}
|
269 |
+
?>
|
270 |
+
</p>
|
271 |
+
</form>
|
272 |
+
<?php
|
273 |
+
//Just get out if nothing else matters...
|
274 |
+
if (get_option('mc_username') == '') return;
|
275 |
+
|
276 |
+
if (get_option('mc_list_id')==''){
|
277 |
+
?>
|
278 |
+
<form method="post" action="options-general.php?page=mc_setup_page">
|
279 |
+
<?php wp_nonce_field('update-options'); ?>
|
280 |
+
<h3>Your Lists</h3>
|
281 |
+
Please select the List you wish to create a Signup Form for.<br/>
|
282 |
+
<?php
|
283 |
+
$api = new MCAPI(get_option('mc_username'), get_option('mc_password'));
|
284 |
+
$lists = $api->lists();
|
285 |
+
rsort($lists);
|
286 |
+
foreach ($lists as $list){
|
287 |
+
echo '<input type="radio" name="mc_list_id" value="'.$list['id'].'"> <strong>'.$list['name'].'</strong><br/>';
|
288 |
+
}
|
289 |
+
if (sizeof($lists)==0){
|
290 |
+
echo "<span class='error_msg'>Uh-oh, you don't have any lists defined! Please visit <a href='http://www.mailchimp.com/'>MailChimp</a>, login, and setup a list before using this tool!</span>";
|
291 |
+
}
|
292 |
+
?>
|
293 |
+
<p class="submit">
|
294 |
+
<input type="hidden" name="action" value="update" />
|
295 |
+
<input type="hidden" name="page_options" value="mc_list_id" />
|
296 |
+
<input type="submit" name="Submit" value="Select List!" class="button" />
|
297 |
+
</p>
|
298 |
+
</form>
|
299 |
+
<?php
|
300 |
+
} //end select list
|
301 |
+
else {
|
302 |
+
//display the selected list...
|
303 |
+
?>
|
304 |
+
<form method="post" action="options-general.php?page=mc_setup_page">
|
305 |
+
<?php wp_nonce_field('update-options'); ?>
|
306 |
+
<p class="submit">
|
307 |
+
<input type="hidden" name="action" value="update" />
|
308 |
+
<input type="hidden" name="page_options" value="mc_list_id" />
|
309 |
+
<input type="submit" name="reset_list" value="Reset List Options and Select again" class="button" />
|
310 |
+
</p>
|
311 |
+
</form>
|
312 |
+
<h3>Subscribe Form Widget Settings for this List:</h3>
|
313 |
+
<h4>Selected MailChimp List: <?php echo get_option('mc_list_name'); ?></h4>
|
314 |
+
<?php
|
315 |
+
}
|
316 |
+
//Just get out if nothing else matters...
|
317 |
+
if (get_option('mc_list_id') == '') return;
|
318 |
+
|
319 |
+
$mv = unserialize(get_option('mc_merge_vars'));
|
320 |
+
$ig = unserialize(get_option('mc_interest_groups'));
|
321 |
+
?>
|
322 |
+
<form method="post" action="options-general.php?page=mc_setup_page">
|
323 |
+
<?php wp_nonce_field('update-options'); ?>
|
324 |
+
<div style="width:600px;">
|
325 |
+
<table class="widefat">
|
326 |
+
<tr valign="top">
|
327 |
+
<th scope="row">Header content:</th>
|
328 |
+
<td>
|
329 |
+
<textarea name="mc_header_content" cols="50"><?php echo get_option('mc_header_content');?></textarea><br/>
|
330 |
+
<i>You can fill this with your own Text, HTML markup (including image links), or Nothing!</i>
|
331 |
+
</td>
|
332 |
+
</tr>
|
333 |
+
|
334 |
+
<tr valign="top">
|
335 |
+
<th scope="row">Submit Button text:</th>
|
336 |
+
<td>
|
337 |
+
<input type="text" name="mc_submit_text" size="30" value="<?php echo get_option('mc_submit_text');?>"/><br/>
|
338 |
+
<i>You can fill this with your own Text, HTML markup (including image links), or Nothing!</i>
|
339 |
+
</td>
|
340 |
+
</tr>
|
341 |
+
|
342 |
+
<tr valign="top">
|
343 |
+
<th scope="row">Custom Styling:</th>
|
344 |
+
<td>
|
345 |
+
<table class="widefat">
|
346 |
+
<tr><th>Turned On?</th><td><input type="checkbox" name="mc_custom_style" <?php if (get_option('mc_custom_style')=='on'){echo 'checked';}?> ></td></tr>
|
347 |
+
<tr><th>Border Width:</th><td><input type="text" name="mc_form_border_width" size="3" maxlength="3" value="<?php echo get_option('mc_form_border_width');?>"> px<br/>
|
348 |
+
<i>Set to 0 for no border, do not enter <strong>px</strong>!</i>
|
349 |
+
</td></tr>
|
350 |
+
<tr><th>Border Color:</th><td>#<input type="text" name="mc_form_border_color" size="7" maxlength="6" value="<?php echo get_option('mc_form_border_color');?>"><br/>
|
351 |
+
<i>do not enter initial <strong>#</strong></i>
|
352 |
+
</td></tr>
|
353 |
+
<tr><th>Text Color:</th><td>#<input type="text" name="mc_form_text_color" size="7" maxlength="6" value="<?php echo get_option('mc_form_text_color');?>"><br/>
|
354 |
+
<i>do not enter initial <strong>#</strong></i>
|
355 |
+
</td></tr>
|
356 |
+
<tr><th>Background Color:</th><td>#<input type="text" name="mc_form_background" size="7" maxlength="6" value="<?php echo get_option('mc_form_background');?>"><br/>
|
357 |
+
<i>do not enter initial <strong>#</strong></i>
|
358 |
+
</td></tr>
|
359 |
+
</table>
|
360 |
+
</td>
|
361 |
+
</tr>
|
362 |
+
</table>
|
363 |
+
</div>
|
364 |
+
|
365 |
+
<div style="width:400px;">
|
366 |
+
<h4>Merge Variables Included</h4>
|
367 |
+
<?php
|
368 |
+
if (sizeof($mv)==0){
|
369 |
+
echo "<i>No Merge Variables found.</i>";
|
370 |
+
} else {
|
371 |
+
?>
|
372 |
+
|
373 |
+
<table class='widefat'>
|
374 |
+
<tr valign="top">
|
375 |
+
<th>Name</th>
|
376 |
+
<th>Tag</th>
|
377 |
+
<th>Required?</th>
|
378 |
+
<th>Include?</th>
|
379 |
+
</tr>
|
380 |
+
<?php
|
381 |
+
foreach($mv as $var){
|
382 |
+
echo '<tr valign="top">
|
383 |
+
<td>'.$var['name'].'</td>
|
384 |
+
<td>'.$var['tag'].'</td>
|
385 |
+
<td>'.($var['req']==1?'Y':'N').'</td><td>';
|
386 |
+
if (!$var['req']){
|
387 |
+
$opt = 'mc_mv_'.$var['tag'];
|
388 |
+
echo '<input name="'.$opt.'" type="checkbox" ';
|
389 |
+
if (get_option($opt)=='on') { echo ' checked '; }
|
390 |
+
echo 'id="'.$opt.'" class="code" />';
|
391 |
+
} else {
|
392 |
+
echo ' - ';
|
393 |
+
}
|
394 |
+
echo '</td></tr>';
|
395 |
+
}
|
396 |
+
echo '</table>';
|
397 |
+
}
|
398 |
+
echo '<h4>Interest Groups</h4>';
|
399 |
+
if ($ig=='' || $ig=='N'){
|
400 |
+
echo "<i>No Interest Groups Setup</i>";
|
401 |
+
} else {
|
402 |
+
?>
|
403 |
+
<table class='widefat'>
|
404 |
+
<tr valign="top">
|
405 |
+
|
406 |
+
<th width="75px">Show?</th><th>
|
407 |
+
<input name="mc_show_interest_groups" type="checkbox" <?php if (get_option('mc_show_interest_groups')=='on') { echo 'checked'; } ?> id="mc_show_interest_groups" class="code" />
|
408 |
+
</th></tr>
|
409 |
+
<tr valign="top">
|
410 |
+
<th>Name:</th><th><?php echo $ig['name']; ?></th>
|
411 |
+
</tr>
|
412 |
+
<tr valign="top">
|
413 |
+
<th>Input Type:</th><td><?php echo $ig['form_field']; ?></td>
|
414 |
+
</tr>
|
415 |
+
<tr valign="top">
|
416 |
+
<th>Options:</th><td><ul>
|
417 |
+
<?php
|
418 |
+
foreach($ig['groups'] as $interest){
|
419 |
+
echo '<li>'.$interest;
|
420 |
+
}
|
421 |
+
echo '</ul></td></tr></table>';
|
422 |
+
}
|
423 |
+
echo '</div>';
|
424 |
+
?>
|
425 |
+
<p class="submit">
|
426 |
+
<input type="hidden" name="action" value="update" />
|
427 |
+
<input type="submit" name="change_form_settings" value="Update Subscribe Form Settings" class="button" />
|
428 |
+
</p>
|
429 |
+
</form>
|
430 |
+
</div>
|
431 |
+
<?php
|
432 |
+
}//mc_setup_page()
|
433 |
+
|
434 |
+
|
435 |
+
add_action('plugins_loaded', 'mc_register_widgets');
|
436 |
+
function mc_register_widgets(){
|
437 |
+
|
438 |
+
if (!function_exists('register_sidebar_widget')) {
|
439 |
+
return;
|
440 |
+
}
|
441 |
+
register_sidebar_widget('MailChimp Widget', 'mc_display_widget');
|
442 |
+
|
443 |
+
}
|
444 |
+
function mc_display_widget(){
|
445 |
+
$mv = unserialize(get_option('mc_merge_vars'));
|
446 |
+
$ig = unserialize(get_option('mc_interest_groups'));
|
447 |
+
$msg = '';
|
448 |
+
if (isset($_REQUEST['mc_signup'])){
|
449 |
+
$failed = false;
|
450 |
+
$listId = get_option('mc_list_id');
|
451 |
+
$email = $_REQUEST['mc_mv_EMAIL'];
|
452 |
+
$merge = array();
|
453 |
+
$errs = array();
|
454 |
+
foreach($mv as $var){
|
455 |
+
$opt = 'mc_mv_'.$var['tag'];
|
456 |
+
if ($var['req']=='Y' && trim($_REQUEST[$opt])==''){
|
457 |
+
$failed = true;
|
458 |
+
$errs[] = 'You must fill in "'.$var['name'].'"!';
|
459 |
+
} else {
|
460 |
+
if ($var['tag']!='EMAIL'){
|
461 |
+
$merge[$var['tag']] = $_REQUEST[$opt];
|
462 |
+
}
|
463 |
+
}
|
464 |
+
}
|
465 |
+
reset($mv);
|
466 |
+
if (get_option('mc_show_interest_groups')){
|
467 |
+
if ($ig['form_field']=='radio' || $ig['form_field']=='select'){
|
468 |
+
$merge['INTERESTS'] = $_REQUEST['interests'];
|
469 |
+
} elseif($ig['form_field']=='checkbox') {
|
470 |
+
if (isset($_REQUEST['interests'])){
|
471 |
+
$merge['INTERESTS'] = implode(',',array_keys($_REQUEST['interests']));
|
472 |
+
}
|
473 |
+
}
|
474 |
+
}
|
475 |
+
if (!$failed){
|
476 |
+
if (sizeof($merge) == 0){ $merge = array(''); }
|
477 |
+
$api = new MCAPI(get_option('mc_username'), get_option('mc_password'));
|
478 |
+
$retval = $api->listSubscribe( $listId, $email, $merge);
|
479 |
+
if (!$retval){
|
480 |
+
$failed = true;
|
481 |
+
$errs[] = $api->errorMessage;
|
482 |
+
} else {
|
483 |
+
$msg = "<br/><strong class='success_msg'>Success, you've been signed up! Please look for our confirmation email!</strong><br/>";
|
484 |
+
}
|
485 |
+
}
|
486 |
+
if (sizeof($errs)>0){
|
487 |
+
$msg = '<br/>Uhoh, we had problems!<ul>';
|
488 |
+
foreach($errs as $error){
|
489 |
+
$msg .= '<li class="error_msg">'.$error.'</li>';
|
490 |
+
}
|
491 |
+
$msg .= '</ul><br/>';
|
492 |
+
}
|
493 |
+
}
|
494 |
+
$uid = get_option('mc_user_id');
|
495 |
+
$list_name = get_option('mc_list_name');
|
496 |
+
?>
|
497 |
+
<div class="mc_custom_border">
|
498 |
+
<a name="mc_signup_form"></a>
|
499 |
+
<?php echo get_option('mc_header_content');?>
|
500 |
+
<form method="POST" action="<?php echo $_SERVER['REQUEST_URI']; ?>#mc_signup_form">
|
501 |
+
<?php
|
502 |
+
if ($msg != ''){
|
503 |
+
echo '<span class="updated">'.$msg.'</span>';
|
504 |
+
}
|
505 |
+
foreach($mv as $var){
|
506 |
+
$opt = 'mc_mv_'.$var['tag'];
|
507 |
+
if ($var['req'] || get_option($opt)=='on'){
|
508 |
+
echo ''.$var['name'].':<br/><input type="text" size="20" value="" name="'.$opt.'">';
|
509 |
+
if ($var['req']){ echo '*'; }
|
510 |
+
echo '<br/>';
|
511 |
+
}
|
512 |
+
}
|
513 |
+
echo '<sup style="clear:both;">* = required field</sup>';
|
514 |
+
if (get_option('mc_show_interest_groups')=='on'){
|
515 |
+
echo '<br/><br/><strong>'.$ig['name'].'</strong><br/>';
|
516 |
+
if ($ig['form_field']=='checkbox'){
|
517 |
+
foreach($ig['groups'] as $interest){
|
518 |
+
echo '<input type="checkbox" name="interests['.$interest.']">'.$interest.'<br/>';
|
519 |
+
}
|
520 |
+
} elseif ($ig['form_field']=='radio'){
|
521 |
+
foreach($ig['groups'] as $interest){
|
522 |
+
echo '<input type="radio" name="interests">'.$interest.'<br/>';
|
523 |
+
}
|
524 |
+
} elseif ($ig['form_field']=='select'){
|
525 |
+
echo '<select name="interests">';
|
526 |
+
foreach($ig['groups'] as $interest){
|
527 |
+
echo '<option value="'.$interest.'">'.$interest.'</option>';
|
528 |
+
}
|
529 |
+
echo '</select>';
|
530 |
+
}
|
531 |
+
}
|
532 |
+
?>
|
533 |
+
<div class="submit">
|
534 |
+
<input type="submit" name="mc_signup" value="<?php echo get_option('mc_submit_text'); ?>" class="button"/>
|
535 |
+
</div>
|
536 |
+
</form>
|
537 |
+
<?php
|
538 |
+
if ( get_option('mc_rewards')=='on') {
|
539 |
+
echo '<div align="center">powered by <a href="http://www.mailchimp.com/affiliates/?aid='.get_option('mc_user_id').'&afl=1">MailChimp</a>!</div>';
|
540 |
+
}
|
541 |
+
?>
|
542 |
+
</div>
|
543 |
+
<?php
|
544 |
+
|
545 |
+
}
|
546 |
+
|
547 |
+
?>
|
readme.txt
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== MailChimp List Subscribe Form ===
|
2 |
+
Contributors: mc_jesse
|
3 |
+
Tags: mailchimp, email, newsletter, signup, marketing, plugin, widget
|
4 |
+
Requires at least: 2.3
|
5 |
+
Tested up to: 2.5.1
|
6 |
+
Stable tag: 0.2
|
7 |
+
Author URI: http://www.mailchimp.com/api/
|
8 |
+
Plugin URI: http://www.mailchimp.com/plugins/wordpress.phtml
|
9 |
+
|
10 |
+
The MailChimp plugin allows you to quickly and easily add a signup form for your MailChimp list.
|
11 |
+
|
12 |
+
== Description ==
|
13 |
+
|
14 |
+
The MailChimp plugin allows you to quickly and easily add a signup form for your MailChimp list as a widget
|
15 |
+
on your Wordpress 2.3 or higher site.
|
16 |
+
|
17 |
+
Not sure what [MailChimp](http://www.mailchimp.com/learnmore.phtml) is or if it will be helpful? Signup up for a
|
18 |
+
[FREE Trial Account](http://www.mailchimp.com/tryit.phtml) and see for yourself!
|
19 |
+
|
20 |
+
After Installation, the setup page will guide you through entering your Login informaiton, selecting your List from our Service,
|
21 |
+
selecting options for the Merge Fields and Interest Groups you have setup, and then add the Widget to your site. The
|
22 |
+
time from starting installation to have the form on your site should be less than 5 minutes - absolutely everything
|
23 |
+
can be done via the Wordpress Setting GUI - no file editing at all!
|
24 |
+
|
25 |
+
You can also visit our [homepage for the plugin](http://www.mailchimp.com/plugins/wordpress.phtml), but if you are reading this,
|
26 |
+
you probably don't need to.
|
27 |
+
|
28 |
+
== Installation ==
|
29 |
+
|
30 |
+
This section describes how to install the plugin and get started using it.
|
31 |
+
|
32 |
+
= Version 2.3 =
|
33 |
+
1. Unzip our archive and upload the entire `mailchimp` directory to your `/wp-content/plugins/` directory
|
34 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress
|
35 |
+
1. Go to Options and look for "MailChimp Setup" in the menu at the top
|
36 |
+
1. Enter your MailChimp Username & Password and let the plugin verify them
|
37 |
+
1. Select One of your lists to have your visitors subscribe to.
|
38 |
+
1. (optionally) Turn on or off the Monkey Rewards option
|
39 |
+
1. (optionally) Turn your Merge Vars and Interest Groups `on` and `off`
|
40 |
+
1. Finally, go to Presentation->Widgets and enable the `MailChimp` widget
|
41 |
+
1. And you are DONE!
|
42 |
+
|
43 |
+
= Version 2.5 =
|
44 |
+
1. Unzip our archive and upload the entire `mailchimp` directory to your `/wp-content/plugins/` directory
|
45 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress
|
46 |
+
1. Go to Settings and look for "MailChimp Setup" in the menu
|
47 |
+
1. Enter your MailChimp Username & Password and let the plugin verify them
|
48 |
+
1. Select One of your lists to have your visitors subscribe to.
|
49 |
+
1. (optionally) Turn on or off the Monkey Rewards option
|
50 |
+
1. (optionally) Turn your Merge Vars and Interest Groups `on` and `off`
|
51 |
+
1. Finally, go to Manage->Widgets and enable the `MailChimp` widget
|
52 |
+
1. And you are DONE!
|
53 |
+
|
54 |
+
= Advanced =
|
55 |
+
If you have a custom coded sidebar or something else special going on where you can't simply enable the widget
|
56 |
+
through the Wordpress GUI, all you need to do is add:
|
57 |
+
|
58 |
+
` mc_display_widget(); `
|
59 |
+
|
60 |
+
Where ever you want it to show up.
|
61 |
+
|
62 |
+
|
63 |
+
== Frequently Asked Questions ==
|
64 |
+
|
65 |
+
= What in the world is MailChimp? =
|
66 |
+
|
67 |
+
Good question! [MailChimp](http://www.mailchimp.com/learnmore.phtml) is full of useful, powerful email marketing features that are easy to use and even a little fun (that's right---we said fun), whether you're an email marketing expert, or a small business just getting started.
|
68 |
+
|
69 |
+
To learn more, just check out our site: [MailChimp](http://www.mailchimp.com/learnmore.phtml)
|
70 |
+
|
71 |
+
|
72 |
+
= Wait a minute, you want me to pay to try this? =
|
73 |
+
|
74 |
+
*Absolutely not!* We welcome you to come signup for a [FREE Trial Account](http://www.mailchimp.com/tryit.phtml) and
|
75 |
+
see if you find it useful.
|
76 |
+
|
77 |
+
|
78 |
+
== Screenshots ==
|
79 |
+
|
80 |
+
1. Entering your MailChimp login info
|
81 |
+
2. Selecting your MailChimp list
|
82 |
+
3. Configuring your Signup Form display format (optional)
|
83 |
+
4. Configuring extra fields on your Signup Form (optional)
|
84 |
+
5. An example Signup Form Widget
|
85 |
+
|
screenshot-1.jpg
ADDED
Binary file
|
screenshot-2.jpg
ADDED
Binary file
|
screenshot-3.jpg
ADDED
Binary file
|
screenshot-4.jpg
ADDED
Binary file
|
screenshot-5.jpg
ADDED
Binary file
|