title: Basic MailChimp API help needed
body: <p>I'm looking for some help figuring out why this basic script isn't working for me. I'm attempting to use the <a href="http://apidocs.mailchimp.com/api/1.3/" rel="nofollow">MailChimp API</a> to have a custom form add new subscribers to a list. The script isn't returning anything.</p>
  
  <p>I know I'm using the API correctly, because when I type the url directly into my browser, the object is subscribed in MailChimp, which makes me think curl isn't set up right. Any thoughts, please?</p>
  
  <pre><code>&lt;?php
  $apikey = 'xxx';
  $listID = 'yyy';
  
  $email = htmlspecialchars(stripslashes(trim($_POST['EMAIL'])));
  $fname = htmlspecialchars(stripslashes(trim($_POST['FNAME'])));
  $lname = htmlspecialchars(stripslashes(trim($_POST['LNAME'])));
  
          if (!empty($_POST['EMAIL_UPDATES'])) {
              $url = sprintf('http://us6.api.mailchimp.com/1.3/?method=listSubscribe&amp;apikey=%s&amp;id=%s&amp;email_address=%s&amp;merge_vars[OPTINIP]=%s&amp;merge_vars[FNAME]=%s&amp;merge_vars[LNAME]=%s&amp;merge_vars[ZIP]=%s&amp;output=json', $apikey, $listID, $email, $_SERVER['REMOTE_ADDR'], $fname, $lname);
              $ch = curl_init($url);
              curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
              $data = curl_exec($ch);
              curl_close($ch);
              $arr = json_decode($data, true);
              if ($arr == 1) {
                  echo 'Check your e-mail and confirm your subscription.';
              } else {
                  switch ($arr['code']) {
                      case 214:
                      echo 'You are already subscribed.';
                      break;
                      // check the MailChimp API for more options
                      default:
                      echo 'Unknown error.';
                      break;          
                  }
              }
          }
  ?&gt;
  </code></pre>