title: Viewing segments via the MailChimp export api
body: <p>I'm having trouble using the API to view a segment. I'm using PHP. My code is as follows:</p>
  
  <pre><code>$url = "https://us7.api.mailchimp.com/export/1.0/list/?apikey=$api_key&amp;id=$list_id&amp;$segment"; 
  $result = file_get_contents($url);
  </code></pre>
  
  <p>where <code>$segment</code> is an array used to generate the segment. </p>
  
  <p>I can get the following version working...</p>
  
  <pre><code>$segment = "segment[match]=all"
             "&amp;segment[conditions][0][field]=LNAME".
             "&amp;segment[conditions][0][op]=like".           
             "&amp;segment[conditions][0][value]=smith";
  </code></pre>
  
  <p>which generates a segment of all subscribers to my list with a last name containing "smith".</p>
  
  <p>However, what I actually want to do is generate a segment based on people who've been sent any mailer in the last 7 days. I've created this manually to get the correct fields and generated the following array based on it:</p>
  
  <pre><code>$segment = "segment[match]=all".
             "&amp;segment[conditions][0][condition_type]=Aim".
             "&amp;segment[conditions][0][field]=aim".
             "&amp;segment[conditions][0][op]=sent".
             "&amp;segment[conditions][0][value]=last7day";
  </code></pre>
  
  <p>but it's giving me a 300 error. This isn't listed in MailChimp's current error glossary on the export api documentation, but according to a snapshot of the old error documentation means "Campaign doesn't exist" (<a href="https://web.archive.org/web/20130209144951/https://apidocs.mailchimp.com/api/1.3/exceptions.field.php" rel="nofollow noreferrer">https://web.archive.org/web/20130209144951/https://apidocs.mailchimp.com/api/1.3/exceptions.field.php</a>) which is weird because I'm not referencing a campaign.</p>
  
  <p>What am I doing wrong?</p>