From: Steve Sutton Date: Thu, 27 Jun 2013 15:58:46 +0000 (+0000) Subject: Setting up for MailChimp X-Git-Tag: v1.0~105 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=7fcf09c775787f24576302473949de90a89c0dca;p=web%2FMichiganTrailMaps.git Setting up for MailChimp example.php for testing working with Mailchimp API adding to application.ini setting file the api key and list id --- diff --git a/Toolkit/LeadManager/MailChimp.php b/Toolkit/LeadManager/MailChimp.php new file mode 100644 index 0000000..ce6a722 --- /dev/null +++ b/Toolkit/LeadManager/MailChimp.php @@ -0,0 +1,62 @@ + + * @copyright 2013 Gaslight Media + * @license Gaslight Media + * @version SVN: (0.1) + * @link <> + */ + +require_once GLM_APP_BASE . 'Common/LeadManager/Affiliates/MCAPI.class.php'; +/** + * Require the MCAPI Class + */ +/** + * Toolkit_LeadManager_MailChimp + * + * This class is an Observer class for setting up the contact forms + * with the ablity to send contact data to the MailChimp list. + * + * @category Toolkit + * @package LeadManager + * @author Steve Sutton + * @copyright 2013 Gaslight Media + * @license Gaslight Media + * @release Release: (0.1) + * @link <> + */ +class Toolkit_LeadManager_MailChimp + extends Toolkit_LeadManager_Observer +{ + public function send(Toolkit_LeadManager_Lead $subject) + { + // have to convert the $subject Object to an array to be used + // in the mailchimp call to add to list + $values = array( + 'email_address' => $subject->getEmail(), + 'first_name' => $subject->getFname(), + 'last_name' => $subject->getLname(), + 'city_name' => $subject->getCity(), + 'state_code' => $subject->getState(), + 'state_name' => $GLOBALS['states'][$subject->getState()], + 'zip_code' => $subject->getZip(), + 'home_number' => $subject->getPhone() + ); + if (is_a($subject, 'Toolkit_LeadManager_Contact')) { + $values['address_line_1'] = $subject->getAddress(); + $values['address_line_2'] = $subject->getAddress2(); + } else if (is_a($subject, 'Toolkit_LeadManager_Customer')) { + $values['address_line_1'] = $subject->getAdd1(); + $values['address_line_2'] = $subject->getAdd2(); + } + } + + +} diff --git a/config/application.ini b/config/application.ini index 3035774..2175994 100644 --- a/config/application.ini +++ b/config/application.ini @@ -43,6 +43,13 @@ constantcontact.apipath = Off ; example BeaverIslandBoatCo/lists/1 constantcontact.list.0 = Off +; MAILCHIMP API +contactdb.mcapi.application = On +; Mailchimp API key +contactdb.mcapi.apikey = "008fe0f365c71f5ea08aed546da40242-us6" +; Mailchimp List Id +contactdb.mcapi.listId = "8ed24143f7" + ; Turn the coupon application On or Off coupons.application = Off diff --git a/example.php b/example.php new file mode 100644 index 0000000..3be8a28 --- /dev/null +++ b/example.php @@ -0,0 +1,32 @@ +lists(); +echo print_r($ret); +exit; +$mergVars = array( + 'FNAME' => 'Test', + 'LNAME' => 'Account', +// 'GROUPINGS' => array( +// array('name' => 'Your Interests:', 'groups'=>'Bananas,Apples') +// ) +); +$retVal = $api->listSubscribe(MAILCHIMP_LISTID, $testEmail, $mergVars); + +if ($api->errorCode) { + echo "Unable to load listSubscribe()!\n"; + echo "\tCode=" . $api->errorCode. "\n"; + echo "\tMsg=" . $api->errorMessage. "\n"; +} else { + echo "Subscribed - look for the confirmation email!\n"; +} + diff --git a/setup.phtml b/setup.phtml index 02b9229..3ea21d1 100644 --- a/setup.phtml +++ b/setup.phtml @@ -356,6 +356,9 @@ define( 'CONSTANT_CONTACT_LIST', serialize($applicationConfig->constantcontact->list->toArray()) ); +define('MAILCHIMP_APP', $applicationConfig->contactdb->mcapi->application); +define('MAILCHIMP_APIKEY', $applicationConfig->contactdb->mcapi->apikey); +define('MAILCHIMP_LISTID', $applicationConfig->contactdb->mcapi->listId); /** * Coupons Database Installed? */