Export API

260 views
Skip to first unread message

kopper

unread,
Oct 26, 2010, 9:57:49 PM10/26/10
to MailChimp API Discuss
Hi,
Anyone can help me about Export API on how to pass segment as
parameter. I have followed this document http://www.mailchimp.com/api/export/
but could not see anywhere in PHP example. also I have tried many
things but non of them works.
Can someone show me some PHP example on how to export list by specific
group of segment.

Thank you

jesse

unread,
Oct 27, 2010, 1:43:29 PM10/27/10
to MailChimp API Discuss
The format for segments there is the same as used by campaignCreate()
and campaignSegmentTest(). As you'll see, the former points to the
latter for documentation:
http://www.mailchimp.com/api/1.2/campaignsegmenttest.func.php


jesse

On Oct 26, 9:57 pm, kopper <thong...@gmail.com> wrote:
> Hi,
> Anyone can help me about Export API on how to pass segment as
> parameter. I have followed this documenthttp://www.mailchimp.com/api/export/

jesse

unread,
Oct 27, 2010, 1:46:01 PM10/27/10
to MailChimp API Discuss
I just realized the Export API docs point to that documentation as
well. Assuming the docs didn't help, check the xml-
rpc_campaignSegmentTest.php example code in the MCAPI wrapper
download.


jesse

On Oct 26, 9:57 pm, kopper <thong...@gmail.com> wrote:
> Hi,
> Anyone can help me about Export API on how to pass segment as
> parameter. I have followed this documenthttp://www.mailchimp.com/api/export/
Message has been deleted

kopper

unread,
Oct 28, 2010, 4:05:23 AM10/28/10
to MailChimp API Discuss
Hi jesse

Still doesn't work I've got the follows error:

stdClass Object ( [error] => "match" must be "any" or "all" [code] =>
506 )

when I run this PHP snippet

$apikey = 'sssssssssssssssssssssss';
$list_id = 'xxxxxx';
$chunk_size = 4096;
$conditions = array();
$conditions[] = array('field'=>'email', 'op'=>'like',
'value'=>'testm...@email.com');
$seg = array('match'=>'all', 'conditions'=>$conditions);

$url = 'http://us1.api.mailchimp.com/export/1.0/list?apikey='.
$apikey.'&id='.$list_id.'&segment='.$seg;

$handle = @fopen($url,'r');
if (!$handle) {
echo "failed to access url\n";
} else {

// do somthing here when get the result

}

Any idea?

jesse

unread,
Oct 28, 2010, 10:12:26 AM10/28/10
to MailChimp API Discuss
I see you pulled down the post that included your API Key - I've
disabled it anyway since there are plenty of folks who receive emails
and have it sitting there. I do not suggest you re-enable it.

If you print out the full url your are building you'll see the problem
pretty quickly. You have to manually serialize the array you are
creating before trying to just stick it in there. If you are not
familiar with building arrays in urls, take a look at how it's done
for the GROUPINGS parameter here:
http://www.mailchimp.com/api/how-to/#ex3


jesse

Stephanie Chizek

unread,
Jul 23, 2013, 7:38:22 PM7/23/13
to mailchimp-...@googlegroups.com, thon...@gmail.com
Sorry I know this is old, but might help others...  Try changing these lines...

$seg = array('segment' => array('match'=>'all', 'conditions'=>$conditions)); 
$url = 'http://us1.api.mailchimp.com/export/1.0/list?apikey='.$apikey.'&id='.$list_id.'&'.urldecode(http_build_query($seg)); 
Reply all
Reply to author
Forward
0 new messages