コード例 #1
0
 /**
  * Use MailChimp API key to try to grab corresponding user profile to check validity of key
  *
  * @param string
  * @return bool    
  */
 function li_check_invalid_api_key($api_key)
 {
     $cm = new LI_Campaign_Monitor($api_key);
     $test = $cm->call('clients', 'GET');
     if ($test['code'] >= 400) {
         $invalid_key = TRUE;
     } else {
         $invalid_key = FALSE;
     }
     return $invalid_key;
 }
コード例 #2
0
 /**
  * Adds a subcsriber to a specific list
  *
  * @param   string
  * @param   string
  * @param   string
  * @param   string
  * @param   string
  * @return  int/bool        API status code OR false if api key not set
  */
 function push_contact_to_list($list_id = '', $email = '', $first_name = '', $last_name = '', $phone = '')
 {
     if (isset($this->options['li_cm_api_key']) && $this->options['li_cm_api_key'] && $list_id) {
         $cm = new LI_Campaign_Monitor($this->options['li_cm_api_key']);
         $r = $cm->call('subscribers/' . $list_id, 'POST', array('EmailAddress' => $email, 'Name' => $first_name . ' ' . $last_name, 'Resubscribe' => TRUE));
         if ($r['code'] <= 400) {
             return TRUE;
         } else {
             return FALSE;
         }
     }
     return FALSE;
 }