Exemplo n.º 1
0
 /**
  * Adds a subcsriber to a specific list
  *
  * @param   string
  * @param   array
  * @return  int/bool        API status code OR false if api key not set
  */
 function bulk_push_contact_to_list($list_id = '', $contacts = '')
 {
     if (isset($this->options['li_mls_api_key']) && $this->options['li_mls_api_key'] && $list_id) {
         $MailChimp = new LI_MailChimp($this->options['li_mls_api_key']);
         $batch_contacts = array();
         if (count($contacts)) {
             foreach ($contacts as $contact) {
                 array_push($batch_contacts, array('email' => array('email' => $contact->lead_email), 'merge_vars' => array('EMAIL' => $contact->lead_email, 'FNAME' => $contact->lead_first_name, 'LNAME' => $contact->lead_last_name)));
             }
         }
         $list_updated = $MailChimp->call("lists/batch-subscribe", array("id" => $list_id, "send_welcome" => FALSE, "email_type" => 'html', "update_existing" => TRUE, 'replace_interests' => FALSE, 'double_optin' => FALSE, "batch" => $batch_contacts));
         return $list_updated;
     }
     return FALSE;
 }
Exemplo n.º 2
0
 /**
  * Use MailChimp API key to try to grab corresponding user profile to check validity of key
  *
  * @param string
  * @return bool    
  */
 function li_mls_check_invalid_api_key($api_key)
 {
     $MailChimp = new LI_MailChimp($api_key);
     $user_profile = $MailChimp->call("users/profile");
     if ($user_profile) {
         $invalid_key = FALSE;
     } else {
         $invalid_key = TRUE;
     }
     return $invalid_key;
 }