PageRenderTime 58ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/administrator/components/com_breezingforms/libraries/mailchimp/MCAPI.class.php

https://bitbucket.org/izubizarreta/https-bitbucket.org-bityvip
PHP | 1814 lines | 553 code | 90 blank | 1171 comment | 24 complexity | a37c7561e52348b21672e52378a0e55d MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.0, JSON, GPL-2.0, BSD-3-Clause, LGPL-2.1, MIT

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. defined('_JEXEC') or die('Direct Access to this location is not allowed.');
  3. /**
  4. * BreezingForms - A Joomla Forms Application
  5. * @version 1.8
  6. * @package BreezingForms
  7. * @copyright (C) 2008-2012 by Markus Bopp
  8. * @license Released under the terms of the GNU General Public License
  9. **/
  10. class MCAPI {
  11. var $version = "1.2";
  12. var $errorMessage;
  13. var $errorCode;
  14. /**
  15. * Cache the information on the API location on the server
  16. */
  17. var $apiUrl;
  18. /**
  19. * Default to a 300 second timeout on server calls
  20. */
  21. var $timeout = 300;
  22. /**
  23. * Default to a 8K chunk size
  24. */
  25. var $chunkSize = 8192;
  26. /**
  27. * Cache the user api_key so we only have to log in once per client instantiation
  28. */
  29. var $api_key;
  30. /**
  31. * Cache the user api_key so we only have to log in once per client instantiation
  32. */
  33. var $secure = false;
  34. /**
  35. * Connect to the MailChimp API for a given list.
  36. *
  37. * @param string $apikey Your MailChimp apikey
  38. * @param string $secure Whether or not this should use a secure connection
  39. */
  40. function MCAPI($apikey, $secure=false) {
  41. //do more "caching" of the uuid for those people that keep instantiating this...
  42. $this->secure = $secure;
  43. $this->apiUrl = parse_url("http://api.mailchimp.com/" . $this->version . "/?output=php");
  44. if ( isset($GLOBALS["mc_api_key"]) && $GLOBALS["mc_api_key"]!="" ){
  45. $this->api_key = $GLOBALS["mc_api_key"];
  46. } else {
  47. $this->api_key = $GLOBALS["mc_api_key"] = $apikey;
  48. }
  49. }
  50. function setTimeout($seconds){
  51. if (is_int($seconds)){
  52. $this->timeout = $seconds;
  53. return true;
  54. }
  55. }
  56. function getTimeout(){
  57. return $this->timeout;
  58. }
  59. function useSecure($val){
  60. if ($val===true){
  61. $this->secure = true;
  62. } else {
  63. $this->secure = false;
  64. }
  65. }
  66. /**
  67. * Unschedule a campaign that is scheduled to be sent in the future
  68. *
  69. * @section Campaign Related
  70. * @example mcapi_campaignUnschedule.php
  71. * @example xml-rpc_campaignUnschedule.php
  72. *
  73. * @param string $cid the id of the campaign to unschedule
  74. * @return boolean true on success
  75. */
  76. function campaignUnschedule($cid) {
  77. $params = array();
  78. $params["cid"] = $cid;
  79. return $this->callServer("campaignUnschedule", $params);
  80. }
  81. /**
  82. * Schedule a campaign to be sent in the future
  83. *
  84. * @section Campaign Related
  85. * @example mcapi_campaignSchedule.php
  86. * @example xml-rpc_campaignSchedule.php
  87. *
  88. * @param string $cid the id of the campaign to schedule
  89. * @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>
  90. * @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>
  91. * @return boolean true on success
  92. */
  93. function campaignSchedule($cid, $schedule_time, $schedule_time_b=NULL) {
  94. $params = array();
  95. $params["cid"] = $cid;
  96. $params["schedule_time"] = $schedule_time;
  97. $params["schedule_time_b"] = $schedule_time_b;
  98. return $this->callServer("campaignSchedule", $params);
  99. }
  100. /**
  101. * Resume sending an AutoResponder or RSS campaign
  102. *
  103. * @section Campaign Related
  104. *
  105. * @param string $cid the id of the campaign to pause
  106. * @return boolean true on success
  107. */
  108. function campaignResume($cid) {
  109. $params = array();
  110. $params["cid"] = $cid;
  111. return $this->callServer("campaignResume", $params);
  112. }
  113. /**
  114. * Pause an AutoResponder orRSS campaign from sending
  115. *
  116. * @section Campaign Related
  117. *
  118. * @param string $cid the id of the campaign to pause
  119. * @return boolean true on success
  120. */
  121. function campaignPause($cid) {
  122. $params = array();
  123. $params["cid"] = $cid;
  124. return $this->callServer("campaignPause", $params);
  125. }
  126. /**
  127. * Send a given campaign immediately
  128. *
  129. * @section Campaign Related
  130. *
  131. * @example mcapi_campaignSendNow.php
  132. * @example xml-rpc_campaignSendNow.php
  133. *
  134. * @param string $cid the id of the campaign to resume
  135. * @return boolean true on success
  136. */
  137. function campaignSendNow($cid) {
  138. $params = array();
  139. $params["cid"] = $cid;
  140. return $this->callServer("campaignSendNow", $params);
  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. * Retrieve all templates defined for your user account
  165. *
  166. * @section Campaign Related
  167. * @example mcapi_campaignTemplates.php
  168. * @example xml-rpc_campaignTemplates.php
  169. *
  170. * @return array An array of structs, one for each template (see Returned Fields for details)
  171. * @returnf integer id Id of the template
  172. * @returnf string name Name of the template
  173. * @returnf string layout Layout of the template - "basic", "left_column", "right_column", or "postcard"
  174. * @returnf string preview_image If we've generated it, the url of the preview image for the template
  175. * @returnf array sections associative array of editable sections in the template that can accept custom HTML when sending a campaign
  176. */
  177. function campaignTemplates() {
  178. $params = array();
  179. return $this->callServer("campaignTemplates", $params);
  180. }
  181. /**
  182. * Allows one to test their segmentation rules before creating a campaign using them
  183. *
  184. * @section Campaign Related
  185. * @example mcapi_campaignSegmentTest.php
  186. * @example xml-rpc_campaignSegmentTest.php
  187. *
  188. * @param string $list_id the list to test segmentation on - get lists using lists()
  189. * @param array $options with 2 keys:
  190. 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)
  191. 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:
  192. Field = "<strong>date</strong>" : Select based on various dates we track
  193. Valid Op(eration): <strong>eq</strong> (is) / <strong>gt</strong> (after) / <strong>lt</strong> (before)
  194. Valid Values:
  195. string last_campaign_sent uses the date of the last campaign sent
  196. string campaign_id - uses the send date of the campaign that carriers the Id submitted - see campaigns()
  197. 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
  198. Field = "<strong>interests</strong>":
  199. Valid Op(erations): <strong>one</strong> / <strong>none</strong> / <strong>all</strong>
  200. Valid Values: a comma delimited of interest groups for the list - see listInterestGroups()
  201. Field = "<strong>aim</strong>"
  202. Valid Op(erations): <strong>open</strong> / <strong>noopen</strong> / <strong>click</strong> / <strong>noclick</strong>
  203. Valid Values: "<strong>any</strong>" or a valid AIM-enabled Campaign that has been sent
  204. Field = "<strong>rating</strong>" : allows matching based on list member ratings
  205. Valid Op(erations): <strong>eq</strong> (=) / <strong>ne</strong> (!=) / <strong>gt</strong> (&gt;) / <strong>lt</strong> (&lt;)
  206. Valid Values: a number between 0 and 5
  207. Field = "<strong>ecomm_prod</strong>" or "<strong>ecomm_prod</strong>": allows matching product and category names from purchases
  208. Valid Op(erations):
  209. <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')
  210. Valid Values: any string
  211. Field = "<strong>ecomm_spent_one</strong>" or "<strong>ecomm_spent_all</strong>" : allows matching purchase amounts on a single order or all orders
  212. Valid Op(erations): <strong>gt</strong> (&gt;) / <strong>lt</strong> (&lt;)
  213. Valid Values: a number
  214. Field = "<strong>ecomm_date</strong>" : allow matching based on order dates
  215. Valid Op(eration): <strong>eq</strong> (is) / <strong>gt</strong> (after) / <strong>lt</strong> (before)
  216. Valid Values:
  217. string YYYY-MM-DD - any date in the form of YYYY-MM-DD
  218. 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.
  219. Valid Op(erations): <strong>geoin</strong>
  220. Valid Values: The number of miles an address should be within
  221. Extra Value: The Zip Code to be used as the center point
  222. 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()
  223. Valid Op(erations):
  224. <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')
  225. Valid Values: any string
  226. * @return integer total The total number of subscribers matching your segmentation options
  227. */
  228. function campaignSegmentTest($list_id, $options) {
  229. $params = array();
  230. $params["list_id"] = $list_id;
  231. $params["options"] = $options;
  232. return $this->callServer("campaignSegmentTest", $params);
  233. }
  234. /**
  235. * Create a new draft campaign to send
  236. *
  237. * @section Campaign Related
  238. * @example mcapi_campaignCreate.php
  239. * @example xml-rpc_campaignCreate.php
  240. * @example xml-rpc_campaignCreateABSplit.php
  241. * @example xml-rpc_campaignCreateRss.php
  242. *
  243. * @param string $type the Campaign Type to create - one of "regular", "plaintext", "absplit", "rss", "trans", "auto"
  244. * @param array $options a hash of the standard options for this campaign :
  245. string list_id the list to send this campaign to- get lists using lists()
  246. string subject the subject line for your campaign message
  247. string from_email the From: email address for your campaign message
  248. string from_name the From: name for your campaign message (not an email address)
  249. string to_email the To: name recipients will see (not email address)
  250. integer template_id optional - use this template to generate the HTML content of the campaign
  251. integer folder_id optional - automatically file the new campaign in the folder_id passed
  252. 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.
  253. string title optional - an internal name to use for this campaign. By default, the campaign subject will be used.
  254. boolean authenticate optional - set to true to enable SenderID, DomainKeys, and DKIM authentication, defaults to false.
  255. 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
  256. boolean auto_footer optional Whether or not we should auto-generate the footer for your content. Mostly useful for content from URLs or Imports
  257. boolean inline_css optional Whether or not css should be automatically inlined when this campaign is sent, defaults to false.
  258. 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.
  259. 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.
  260. * @param array $content the content for this campaign - use a struct with the following keys:
  261. "html" for pasted HTML content
  262. "text" for the plain-text version
  263. "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
  264. "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
  265. "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
  266. 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"
  267. * @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.
  268. * @param array $type_opts optional -
  269. For RSS Campaigns this, array should contain:
  270. string url the URL to pull RSS content from - it will be verified and must exist
  271. string schedule optional one of "daily", "weekly", "monthly" - defaults to "daily"
  272. string schedule_hour optional an hour between 0 and 24 - default to 4 (4am <em>local time</em>) - applies to all schedule types
  273. 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)
  274. 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
  275. For A/B Split campaigns, this array should contain:
  276. 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!
  277. 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)
  278. integer wait_units optional the default time unit to wait before auto-selecting a winner - use "3600" for hours, "86400" for days. Defaults to 86400.
  279. integer 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.
  280. integer 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%
  281. string from_name_a optional sort of, required when split_test is "from_name"
  282. string from_name_b optional sort of, required when split_test is "from_name"
  283. string from_email_a optional sort of, required when split_test is "from_name"
  284. string from_email_b optional sort of, required when split_test is "from_name"
  285. string subject_a optional sort of, required when split_test is "subject"
  286. string subject_b optional sort of, required when split_test is "subject"
  287. For AutoResponder campaigns, this array should contain:
  288. string offset-units one of "day", "week", "month", "year" - required
  289. string offset-time the number of units, must be a number greater than 0 - required
  290. string offset-dir either "before" or "after"
  291. string event optional "signup" (default) to base this on double-optin signup, "date" or "annual" to base this on merge field in the list
  292. string event-datemerge optional sort of, this is required if the event is "date" or "annual"
  293. *
  294. * @return string the ID for the created campaign
  295. */
  296. function campaignCreate($type, $options, $content, $segment_opts=NULL, $type_opts=NULL) {
  297. $params = array();
  298. $params["type"] = $type;
  299. $params["options"] = $options;
  300. $params["content"] = $content;
  301. $params["segment_opts"] = $segment_opts;
  302. $params["type_opts"] = $type_opts;
  303. return $this->callServer("campaignCreate", $params);
  304. }
  305. /** Update just about any setting for a campaign that has <em>not</em> been sent. See campaignCreate() for details.
  306. *
  307. *
  308. * Caveats:<br/><ul>
  309. * <li>If you set list_id, all segmentation options will be deleted and must be re-added.</li>
  310. * <li>If you set template_id, you need to follow that up by setting it's 'content'</li>
  311. * <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>
  312. * @section Campaign Related
  313. *
  314. * @example mcapi_campaignUpdate.php
  315. * @example mcapi_campaignUpdateAB.php
  316. * @example xml-rpc_campaignUpdate.php
  317. * @example xml-rpc_campaignUpdateAB.php
  318. *
  319. * @param string $cid the Campaign Id to update
  320. * @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.
  321. * @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.
  322. * @return boolean true if the update succeeds, otherwise an error will be thrown
  323. */
  324. function campaignUpdate($cid, $name, $value) {
  325. $params = array();
  326. $params["cid"] = $cid;
  327. $params["name"] = $name;
  328. $params["value"] = $value;
  329. return $this->callServer("campaignUpdate", $params);
  330. }
  331. /** Replicate a campaign.
  332. *
  333. * @section Campaign Related
  334. *
  335. * @example mcapi_campaignReplicate.php
  336. *
  337. * @param string $cid the Campaign Id to replicate
  338. * @return string the id of the replicated Campaign created, otherwise an error will be thrown
  339. */
  340. function campaignReplicate($cid) {
  341. $params = array();
  342. $params["cid"] = $cid;
  343. return $this->callServer("campaignReplicate", $params);
  344. }
  345. /** Delete a campaign. Seriously, "poof, gone!" - be careful!
  346. *
  347. * @section Campaign Related
  348. *
  349. * @example mcapi_campaignDelete.php
  350. *
  351. * @param string $cid the Campaign Id to delete
  352. * @return boolean true if the delete succeeds, otherwise an error will be thrown
  353. */
  354. function campaignDelete($cid) {
  355. $params = array();
  356. $params["cid"] = $cid;
  357. return $this->callServer("campaignDelete", $params);
  358. }
  359. /**
  360. * Get the list of campaigns and their details matching the specified filters
  361. *
  362. * @section Campaign Related
  363. * @example mcapi_campaigns.php
  364. * @example xml-rpc_campaigns.php
  365. *
  366. * @param array $filters a hash of filters to apply to this query - all are optional:
  367. string campaign_id optional - return a single campaign using a know campaign_id
  368. string list_id optional - the list to send this campaign to- get lists using lists()
  369. integer folder_id optional - only show campaigns from this folder id - get folders using campaignFolders()
  370. string status optional - return campaigns of a specific status - one of "save", "paused", "schedule", "sending"
  371. string type optional - return campaigns of a specific type - one of "regular", "plaintext", "absplit", "rss", "trans", "auto"
  372. string from_name optional - only show campaigns that have this "From Name"
  373. string from_email optional - only show campaigns that have this "Reply-to Email"
  374. string title optional - only show campaigns that have this title
  375. string subject optional - only show campaigns that have this subject
  376. 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)
  377. 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)
  378. boolean exact optional - flag for whether to filter on exact values when filtering, or search within content for filter values - defaults to true
  379. * @param integer $start optional - control paging of campaigns, start results at this campaign #, defaults to 1st page of data (page 0)
  380. * @param integer $limit optional - control paging of campaigns, number of campaigns to return with each call, defaults to 25 (max=1000)
  381. * @return array list of campaigns and their associated information (see Returned Fields for description)
  382. * @returnf string id Campaign Id (used for all other campaign functions)
  383. * @returnf integer web_id The Campaign id used in our web app, allows you to create a link directly to it
  384. * @returnf string title Title of the campaign
  385. * @returnf string type The type of campaign this is (regular,plaintext,absplit,rss,inspection,trans,auto)
  386. * @returnf date create_time Creation time for the campaign
  387. * @returnf date send_time Send time for the campaign - also the scheduled time for scheduled campaigns.
  388. * @returnf integer emails_sent Number of emails email was sent to
  389. * @returnf string status Status of the given campaign (save,paused,schedule,sending,sent)
  390. * @returnf string from_name From name of the given campaign
  391. * @returnf string from_email Reply-to email of the given campaign
  392. * @returnf string subject Subject of the given campaign
  393. * @returnf string to_email Custom "To:" email string using merge variables
  394. * @returnf string archive_url Archive link for the given campaign
  395. * @returnf boolean inline_css Whether or not the campaigns content auto-css-lined
  396. * @returnf string analytics Either "google" if enabled or "N" if disabled
  397. * @returnf string analytcs_tag The name/tag the campaign's links were tagged with if analytics were enabled.
  398. * @returnf boolean track_clicks_text Whether or not links in the text version of the campaign were tracked
  399. * @returnf boolean track_clicks_html Whether or not links in the html version of the campaign were tracked
  400. * @returnf boolean track_opens Whether or not opens for the campaign were tracked
  401. * @returnf string segment_text a string marked-up with HTML explaining the segment used for the campaign in plain English
  402. * @returnf array segment_opts the segment used for the campaign - can be passed to campaignSegmentTest() or campaignCreate()
  403. */
  404. function campaigns($filters=array (
  405. ), $start=0, $limit=25) {
  406. $params = array();
  407. $params["filters"] = $filters;
  408. $params["start"] = $start;
  409. $params["limit"] = $limit;
  410. return $this->callServer("campaigns", $params);
  411. }
  412. /**
  413. * List all the folders for a user account
  414. *
  415. * @section Campaign Related
  416. * @example mcapi_campaignFolders.php
  417. * @example xml-rpc_campaignFolders.php
  418. *
  419. * @return array Array of folder structs (see Returned Fields for details)
  420. * @returnf integer folder_id Folder Id for the given folder, this can be used in the campaigns() function to filter on.
  421. * @returnf string name Name of the given folder
  422. */
  423. function campaignFolders() {
  424. $params = array();
  425. return $this->callServer("campaignFolders", $params);
  426. }
  427. /**
  428. * Given a list and a campaign, get all the relevant campaign statistics (opens, bounces, clicks, etc.)
  429. *
  430. * @section Campaign Stats
  431. *
  432. * @example mcapi_campaignStats.php
  433. * @example xml-rpc_campaignStats.php
  434. *
  435. * @param string $cid the campaign id to pull stats for (can be gathered using campaigns())
  436. * @return array struct of the statistics for this campaign
  437. * @returnf integer syntax_errors Number of email addresses in campaign that had syntactical errors.
  438. * @returnf integer hard_bounces Number of email addresses in campaign that hard bounced.
  439. * @returnf integer soft_bounces Number of email addresses in campaign that soft bounced.
  440. * @returnf integer unsubscribes Number of email addresses in campaign that unsubscribed.
  441. * @returnf integer abuse_reports Number of email addresses in campaign that reported campaign for abuse.
  442. * @returnf integer forwards Number of times email was forwarded to a friend.
  443. * @returnf integer forwards_opens Number of times a forwarded email was opened.
  444. * @returnf integer opens Number of times the campaign was opened.
  445. * @returnf date last_open Date of the last time the email was opened.
  446. * @returnf integer unique_opens Number of people who opened the campaign.
  447. * @returnf integer clicks Number of times a link in the campaign was clicked.
  448. * @returnf integer unique_clicks Number of unique recipient/click pairs for the campaign.
  449. * @returnf date last_click Date of the last time a link in the email was clicked.
  450. * @returnf integer users_who_clicked Number of unique recipients who clicked on a link in the campaign.
  451. * @returnf integer emails_sent Number of email addresses campaign was sent to.
  452. */
  453. function campaignStats($cid) {
  454. $params = array();
  455. $params["cid"] = $cid;
  456. return $this->callServer("campaignStats", $params);
  457. }
  458. /**
  459. * Get an array of the urls being tracked, and their click counts for a given campaign
  460. *
  461. * @section Campaign Stats
  462. *
  463. * @example mcapi_campaignClickStats.php
  464. * @example xml-rpc_campaignClickStats.php
  465. *
  466. * @param string $cid the campaign id to pull stats for (can be gathered using campaigns())
  467. * @return struct urls will be keys and contain their associated statistics:
  468. * @returnf integer clicks Number of times the specific link was clicked
  469. * @returnf integer unique Number of unique people who clicked on the specific link
  470. */
  471. function campaignClickStats($cid) {
  472. $params = array();
  473. $params["cid"] = $cid;
  474. return $this->callServer("campaignClickStats", $params);
  475. }
  476. /**
  477. * Get the top 5 performing email domains for this campaign. Users want more than 5 should use campaign campaignEmailStatsAIM()
  478. * or campaignEmailStatsAIMAll() and generate any additional stats they require.
  479. *
  480. * @section Campaign Stats
  481. *
  482. * @example mcapi_campaignEmailDomainPerformance.php
  483. *
  484. * @param string $cid the campaign id to pull email domain performance for (can be gathered using campaigns())
  485. * @return array domains email domains and their associated stats
  486. * @returnf string domain Domain name or special "Other" to roll-up stats past 5 domains
  487. * @returnf integer total_sent Total Email across all domains - this will be the same in every row
  488. * @returnf integer emails Number of emails sent to this domain
  489. * @returnf integer bounces Number of bounces
  490. * @returnf integer opens Number of opens
  491. * @returnf integer clicks Number of clicks
  492. * @returnf integer unsubs Number of unsubs
  493. * @returnf integer delivered Number of deliveries
  494. * @returnf integer emails_pct Percentage of emails that went to this domain (whole number)
  495. * @returnf integer bounces_pct Percentage of bounces from this domain (whole number)
  496. * @returnf integer opens_pct Percentage of opens from this domain (whole number)
  497. * @returnf integer clicks_pct Percentage of clicks from this domain (whole number)
  498. * @returnf integer unsubs_pct Percentage of unsubs from this domain (whole number)
  499. */
  500. function campaignEmailDomainPerformance($cid) {
  501. $params = array();
  502. $params["cid"] = $cid;
  503. return $this->callServer("campaignEmailDomainPerformance", $params);
  504. }
  505. /**
  506. * Get all email addresses with Hard Bounces for a given campaign
  507. *
  508. * @section Campaign Stats
  509. *
  510. * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
  511. * @param integer $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
  512. * @param integer $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
  513. * @return array Arrays of email addresses with Hard Bounces
  514. */
  515. function campaignHardBounces($cid, $start=0, $limit=1000) {
  516. $params = array();
  517. $params["cid"] = $cid;
  518. $params["start"] = $start;
  519. $params["limit"] = $limit;
  520. return $this->callServer("campaignHardBounces", $params);
  521. }
  522. /**
  523. * Get all email addresses with Soft Bounces for a given campaign
  524. *
  525. * @section Campaign Stats
  526. *
  527. * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
  528. * @param integer $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
  529. * @param integer $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
  530. * @return array Arrays of email addresses with Soft Bounces
  531. */
  532. function campaignSoftBounces($cid, $start=0, $limit=1000) {
  533. $params = array();
  534. $params["cid"] = $cid;
  535. $params["start"] = $start;
  536. $params["limit"] = $limit;
  537. return $this->callServer("campaignSoftBounces", $params);
  538. }
  539. /**
  540. * Get all unsubscribed email addresses for a given campaign
  541. *
  542. * @section Campaign Stats
  543. *
  544. * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
  545. * @param integer $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
  546. * @param integer $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
  547. * @return array list of email addresses that unsubscribed from this campaign
  548. */
  549. function campaignUnsubscribes($cid, $start=0, $limit=1000) {
  550. $params = array();
  551. $params["cid"] = $cid;
  552. $params["start"] = $start;
  553. $params["limit"] = $limit;
  554. return $this->callServer("campaignUnsubscribes", $params);
  555. }
  556. /**
  557. * Get all email addresses that complained about a given campaign
  558. *
  559. * @section Campaign Stats
  560. *
  561. * @example mcapi_campaignAbuseReports.php
  562. *
  563. * @param string $cid the campaign id to pull abuse reports for (can be gathered using campaigns())
  564. * @param integer $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
  565. * @param integer $limit optional for large data sets, the number of results to return - defaults to 500, upper limit set at 1000
  566. * @param string $since optional pull only messages since this time - use YYYY-MM-DD HH:II:SS format in <strong>GMT</strong>
  567. * @return array reports the abuse reports for this campaign
  568. * @returnf string date date/time the abuse report was received and processed
  569. * @returnf string email the email address that reported abuse
  570. * @returnf string type an internal type generally specifying the orginating mail provider - may not be useful outside of filling report views
  571. */
  572. function campaignAbuseReports($cid, $since=NULL, $start=0, $limit=500) {
  573. $params = array();
  574. $params["cid"] = $cid;
  575. $params["since"] = $since;
  576. $params["start"] = $start;
  577. $params["limit"] = $limit;
  578. return $this->callServer("campaignAbuseReports", $params);
  579. }
  580. /**
  581. * Retrieve the text presented in our app for how a campaign performed and any advice we may have for you - best
  582. * suited for display in customized reports pages. Note: some messages will contain HTML - clean tags as necessary
  583. *
  584. * @section Campaign Stats
  585. *
  586. * @example mcapi_campaignAdvice.php
  587. *
  588. * @param string $cid the campaign id to pull advice text for (can be gathered using campaigns())
  589. * @return array advice on the campaign's performance
  590. * @returnf msg the advice message
  591. * @returnf type the "type" of the message. one of: negative, positive, or neutral
  592. */
  593. function campaignAdvice($cid) {
  594. $params = array();
  595. $params["cid"] = $cid;
  596. return $this->callServer("campaignAdvice", $params);
  597. }
  598. /**
  599. * Retrieve the Google Analytics data we've collected for this campaign. Note, requires Google Analytics Add-on to be installed and configured.
  600. *
  601. * @section Campaign Stats
  602. *
  603. * @example mcapi_campaignAnalytics.php
  604. *
  605. * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
  606. * @return array analytics we've collected for the passed campaign.
  607. * @returnf integer visits number of visits
  608. * @returnf integer pages number of page views
  609. * @returnf integer new_visits new visits recorded
  610. * @returnf integer bounces vistors who "bounced" from your site
  611. * @returnf double time_on_site
  612. * @returnf integer goal_conversions number of goals converted
  613. * @returnf double goal_value value of conversion in dollars
  614. * @returnf double revenue revenue generated by campaign
  615. * @returnf integer transactions number of transactions tracked
  616. * @returnf integer ecomm_conversions number Ecommerce transactions tracked
  617. * @returnf array goals an array containing goal names and number of conversions
  618. */
  619. function campaignAnalytics($cid) {
  620. $params = array();
  621. $params["cid"] = $cid;
  622. return $this->callServer("campaignAnalytics", $params);
  623. }
  624. /**
  625. * Retrieve the countries and number of opens tracked for each. Email address are not returned.
  626. *
  627. * @section Campaign Stats
  628. *
  629. *
  630. * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
  631. * @return array countries an array of countries where opens occurred
  632. * @returnf string code The ISO3166 2 digit country code
  633. * @returnf string name A version of the country name, if we have it
  634. * @returnf int opens The total number of opens that occurred in the country
  635. * @returnf bool region_detail Whether or not a subsequent call to campaignGeoOpensByCountry() will return anything
  636. */
  637. function campaignGeoOpens($cid) {
  638. $params = array();
  639. $params["cid"] = $cid;
  640. return $this->callServer("campaignGeoOpens", $params);
  641. }
  642. /**
  643. * Retrieve the regions and number of opens tracked for a certain country. Email address are not returned.
  644. *
  645. * @section Campaign Stats
  646. *
  647. *
  648. * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
  649. * @param string $code An ISO3166 2 digit country code
  650. * @return array regions an array of regions within the provided country where opens occurred.
  651. * @returnf string code An internal code for the region. When this is blank, it indicates we know the country, but not the region
  652. * @returnf string name The name of the region, if we have one. For blank "code" values, this will be "Rest of Country"
  653. * @returnf int opens The total number of opens that occurred in the country
  654. */
  655. function campaignGeoOpensForCountry($cid, $code) {
  656. $params = array();
  657. $params["cid"] = $cid;
  658. $params["code"] = $code;
  659. return $this->callServer("campaignGeoOpensForCountry", $params);
  660. }
  661. /**
  662. * Retrieve the tracked eepurl mentions on Twitter
  663. *
  664. * @section Campaign Stats
  665. *
  666. *
  667. * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
  668. * @return array stats an array containing tweets and retweets including the campaign's eepurl
  669. * @returnf int tweets Total number of tweets seen
  670. * @returnf string first_tweet date and time of the first tweet seen
  671. * @returnf string last_tweet date and time of the last tweet seen
  672. * @returnf int retweets Total number of retweets seen
  673. * @returnf string first_retweet date and time of the first retweet seen
  674. * @returnf string last_retweet date and time of the last retweet seen
  675. * @returnf array statuses an array of statuses recorded inclduing the status, screen_name, status_id, and datetime fields plus an is_retweet flag
  676. */
  677. function campaignEepUrlStats($cid) {
  678. $params = array();
  679. $params["cid"] = $cid;
  680. return $this->callServer("campaignEepUrlStats", $params);
  681. }
  682. /**
  683. * Retrieve the full bounce messages for the given campaign. Note that this can return very large amounts
  684. * of data depending on how large the campaign was and how much cruft the bounce provider returned. Also,
  685. * message over 30 days old are subject to being removed
  686. *
  687. * @section Campaign Stats
  688. *
  689. * @example mcapi_campaignBounceMessages.php
  690. *
  691. * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
  692. * @param integer $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
  693. * @param integer $limit optional for large data sets, the number of results to return - defaults to 25, upper limit set at 50
  694. * @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)
  695. * @return array bounces the full bounce messages for this campaign
  696. * @returnf string date date/time the bounce was received and processed
  697. * @returnf string email the email address that bounced
  698. * @returnf string message the entire bounce message received
  699. */
  700. function campaignBounceMessages($cid, $start=0, $limit=25, $since=NULL) {
  701. $params = array();
  702. $params["cid"] = $cid;
  703. $params["start"] = $start;
  704. $params["limit"] = $limit;
  705. $params["since"] = $since;
  706. return $this->callServer("campaignBounceMessages", $params);
  707. }
  708. /**
  709. * Retrieve the Ecommerce Orders tracked by campaignEcommAddOrder()
  710. *
  711. * @section Campaign Stats
  712. *
  713. * @param string $cid the campaign id to pull bounces for (can be gathered using campaigns())
  714. * @param integer $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
  715. * @param integer $limit optional for large data sets, the number of results to return - defaults to 100, upper limit set at 500
  716. * @param string $since optional pull only messages since this time - use YYYY-MM-DD HH:II:SS format in <strong>GMT</strong>
  717. * @return array orders the orders and their details that we've collected for this campaign
  718. * @returnf store_id string the store id generated by the plugin used to uniquely identify a store
  719. * @returnf store_name string the store name collected by the plugin - often the domain name
  720. * @returnf order_id string the internal order id the store tracked this order by
  721. * @returnf email string the email address that received this campaign and is associated with this order
  722. * @returnf order_total double the order total
  723. * @returnf tax_total double the total tax for the order (if collected)
  724. * @returnf ship_total double the shipping total for the order (if collected)
  725. * @returnf order_date string the date the order was tracked - from the store if possible, otherwise the GMT time we recieved it
  726. * @returnf lines array containing detail of the order - product, category, quantity, item cost
  727. */
  728. function campaignEcommOrders($cid, $start=0, $limit=100, $since=NULL) {
  729. $params = array();
  730. $params["cid"] = $cid;
  731. $params["start"] = $start;
  732. $params["limit"] = $limit;
  733. $params["since"] = $since;
  734. return $this->callServer("campaignEcommOrders", $params);
  735. }
  736. /**
  737. * 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)
  738. *
  739. * @section Campaign Related
  740. *
  741. * @param string $cid the campaign id to share a report for (can be gathered using campaigns())
  742. * @param array $opts optional various parameters which can be used to configure the shared report
  743. string header_type optional - "text" or "image', defaults to "text'
  744. 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.
  745. boolean secure optional - whether to require a password for the shared report. defaults to "true"
  746. string password optional - if secure is true and a password is not included, we will generate one. It is always returned.
  747. string to_email optional - optional, email address to share the report with - no value means an email will not be sent
  748. 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"
  749. 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 characters
  750. * @return struct Struct containing details for the shared report
  751. * @returnf string title The Title of the Campaign being shared
  752. * @returnf string url The URL to the shared report
  753. * @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
  754. * @returnf string password If secured, the password for the report, otherwise this field will not be returned
  755. */
  756. function campaignShareReport($cid, $opts=array (
  757. )) {
  758. $params = array();
  759. $params["cid"] = $cid;
  760. $params["opts"] = $opts;
  761. return $this->callServer("campaignShareReport", $params);
  762. }
  763. /**
  764. * 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
  765. *
  766. * @section Campaign Related
  767. *
  768. * @param string $cid the campaign id to get content for (can be gathered using campaigns())
  769. * @param bool $for_archive optional controls whether we return the Archive version (true) or the Raw version (false), defaults to true
  770. * @return struct Struct containing all content for the campaign (see Returned Fields for details
  771. * @returnf string html The HTML content used for the campgain with merge tags intact
  772. * @returnf string text The Text content used for the campgain with merge tags intact
  773. */
  774. function campaignContent($cid, $for_archive=true) {
  775. $params = array();
  776. $params["cid"] = $cid;
  777. $params["for_archive"] = $for_archive;
  778. return $this->callServer("campaignContent", $params);
  779. }
  780. /**
  781. * 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
  782. * not actually require the AIM module to be installed
  783. *
  784. * @section Campaign AIM
  785. *
  786. * @param string $cid the campaign id to get opens for (can be gathered using campaigns())
  787. * @param integer $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
  788. * @param integer $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
  789. * @return array Array of structs containing email addresses and open counts
  790. * @returnf string email Email address that opened the campaign
  791. * @returnf integer open_count Total number of times the campaign was opened by this email address
  792. */
  793. function campaignOpenedAIM($cid, $start=0, $limit=1000) {
  794. $params = array();
  795. $params["cid"] = $cid;
  796. $params["start"] = $start;
  797. $params["limit"] = $limit;
  798. return $this->callServer("campaignOpenedAIM", $params);
  799. }
  800. /**
  801. * Retrieve the list of email addresses that did not open a given campaign
  802. *
  803. * @section Campaign AIM
  804. *
  805. * @param string $cid the campaign id to get no opens for (can be gathered using campaigns())
  806. * @param integer $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
  807. * @param integer $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
  808. * @return array list of email addresses that did not open a campaign
  809. */
  810. function campaignNotOpenedAIM($cid, $start=0, $limit=1000) {
  811. $params = array();
  812. $params["cid"] = $cid;
  813. $params["start"] = $start;
  814. $params["limit"] = $limit;
  815. return $this->callServer("campaignNotOpenedAIM", $params);
  816. }
  817. /**
  818. * Return the list of email addresses that clicked on a given url, and how many times they clicked
  819. *
  820. * @section Campaign AIM
  821. *
  822. * @param string $cid the campaign id to get click stats for (can be gathered using campaigns())
  823. * @param string $url the URL of the link that was clicked on
  824. * @param integer $start optional for large data sets, the page number to start at - defaults to 1st page of data (page 0)
  825. * @param integer $limit optional for large data sets, the number of results to return - defaults to 1000, upper limit set at 15000
  826. * @return array Array of structs containing email addresses and click counts
  827. * @returnf string email Email address that opened the campaign
  828. * @returnf integer clicks Total number of times the URL was clicked on by this email address
  829. */
  830. function campaignClickDetailAIM($cid, $url, $start=0, $limit=1000) {
  831. $params = array();
  832. $params["cid"] = $cid;
  833. $params["url"] = $url;
  834. $params["start"] = $start;
  835. $params["limit"] = $limit;
  836. return $this->callServer("campaignClickDetailAIM", $params);
  837. }
  838. /**
  839. * Given a campaign and email address, return the entire click and open history with timestamps, ordered by time
  840. *
  841. * @section Campaign AIM
  842. *
  843. * @param string $cid the campaign id to get stats for (can be gathered using campaigns())
  844. * @param string $email_address the email address to check OR the email "id" returned from listMemberInfo, Webhooks, and Campaigns
  845. * @return array Array of structs containing the actions (opens and clicks) that the email took, with timestamps
  846. * @returnf string action The action taken (open or click)
  847. * @returnf d…

Large files files are truncated, but you can click here to view the full file