title: how to add email address to mailchimp list using api call in php
body: <p>i am newbie in mailchimp. just now i have created account and got api key. i have gone through their api for adding email address to the list but didn't help it.</p>
  
  <p>i have contact us form and when user clicks on submit button i want to add user's email id in my mailchimp database. </p>
  
  <p>i have tried with this code also but getting 104 error..</p>
  
  <pre><code>  $apikey = '***********-us3';
                  $listID = '*******';
                  $email = "********";
                  $url = sprintf('https://us2.api.mailchimp.com/2.0/lists/subscribe&amp;apikey=%s&amp;id=%s&amp;email_address=%s&amp;output=json', $apikey, $listID, $email, $_SERVER['REMOTE_ADDR']);
                  $ch = curl_init($url);
                  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                  $data = curl_exec($ch);
                  $arr = json_decode($data, true);
                  curl_close($ch);
          if ($arr == 1) {
              echo 'Check now your e-mail and confirm your subsciption.';
          } else {
                              echo $arr['code'];
              switch ($arr['code']) {
                  case 214:
                  echo 'You are already subscribed.';
                  break;
                  // check the MailChimp API for more options
                  default:
                  echo 'Unkown error...';
                  break;          
              }
          }
  </code></pre>
  
  <p>can anyone suggest me how to achieve it?</p>
  
  <p>Thanks in advance</p>