예제 #1
0
 /**
  * Inscription sur mailchimp
  * @param $mail
  * @param $fstname
  * @param $lstname
  * @param bool $notify
  */
 public function subscribe($mail, $fstname, $lstname, $notify = true)
 {
     if (self::install_table() == true) {
         $api = parent::getApi();
         if ($api != null) {
             $iso = frontend_model_template::current_Language();
             $list = parent::getCode($api['idapi'], $iso);
             if ($list != null) {
                 $code = $list['list_id'];
                 $MailChimp = new \Drewm\MailChimp($api['account_api']);
                 $result = $MailChimp->call('lists/subscribe', array('id' => $code, 'email' => array('email' => $mail), 'merge_vars' => array('FNAME' => $fstname, 'LNAME' => $lstname), 'double_optin' => false, 'update_existing' => true, 'replace_interests' => false, 'send_welcome' => false));
                 if ($notify) {
                     $this->getNotify('add');
                 }
             } else {
                 $this->getNotify('error');
             }
         } else {
             $this->getNotify('error');
         }
     }
 }