--- /dev/null
+<?php
+
+/**
+ * MailChimp.php
+ *
+ * PHP version 5.3
+ *
+ * @category Toolkit
+ * @package LeadManager
+ * @author Steve Sutton <steve@gaslightmedia.com>
+ * @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 <steve@gaslightmedia.com>
+ * @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();
+ }
+
+ // Test if this email is in the list
+ $ch = curl_init();
+ $email = md5( strtolower( $subject->getEmail() ) );
+ $url = 'https://us19.api.mailchimp.com/3.0/lists/'.MAILCHIMP_LISTID.'/members/'. $email;
+ $data = array(
+ 'email_address' => $subject->getEmail(),
+ 'status' => 'pending',
+ 'merge_fields' => array(
+ 'FNAME' => ($subject->getFname())?$subject->getFname():'',
+ 'LNAME' => ($subject->getLname())?$subject->getLname():'',
+ 'PHONE' => ($subject->getPhone())?$subject->getPhone():'',
+ )
+ );
+ // echo '<pre>$data: ' . print_r( $data, true ) . '</pre>';
+ $jsonData = json_encode( $data );
+ curl_setopt_array(
+ $ch,
+ array(
+ CURLOPT_URL => $url,
+ CURLOPT_USERPWD => MAILCHIMP_USER . ':' . MAILCHIMP_APIKEY,
+ CURLOPT_HTTPHEADER => array( 'Content-Type: application/json' ),
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_HEADER => false,
+ CURLOPT_POST => true,
+ CURLOPT_SSL_VERIFYPEER => false,
+ CURLOPT_CUSTOMREQUEST => 'PUT',
+ CURLOPT_POSTFIELDS => $jsonData,
+ )
+ );
+ $output = curl_exec( $ch );
+ // echo '<pre>$output: ' . print_r( json_decode( $output ), true ) . '</pre>';
+ // $info = curl_getinfo( $ch );
+ // echo '<pre>$info: ' . print_r( $info, true ) . '</pre>';
+
+ }
+
+
+}
; STREAM SEND API
; Turn on the streamsend module to use with our contact application
-contactdb.streamsend.application = On
+contactdb.streamsend.application = Off
; Login id for the streamsend account
contactdb.streamsend.login = "7KDfOTJvGNOH"
; Transaction key for the streamsend account
; example BeaverIslandBoatCo/lists/1
constantcontact.list.0 = Off
+; MAILCHIMP API
+contactdb.mcapi.application = On
+; Mailchimp API key
+contactdb.mcapi.apikey = "f78346e39590822f683c7572d25259f2-us19"
+; Mailchimp List Id (List)
+contactdb.mcapi.listId = "8b27bab6a8"
+; Mailchimp username
+contactdb.mcapi.user = "GolfMecca101";
+
; Turn the coupon application On or Off
coupons.application = Off
; development server configuration data inherits from production and
; overrides values as necessary
[development : production]
+contactdb.mcapi.apikey = "bc09e2b095b07e87e65169df37deacfd-us19"
+contactdb.mcapi.listId = "af73c15416"
+contactdb.mcapi.user = "steve@gaslightmedia.com";
; chuck's server configuration data inherits from development
; and overrides values as necessary