MCAPI.class.php 175 KB

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