开发者

How to mail to a static list segment with mailchimp API

Once I've identified identified the email addresses of my list segment (using get_emails() custom function, I am setting up my list segment as follows:

    $batch = get_em开发者_StackOverflow中文版ails();
    //now create my list segment:
    $api->listStaticSegmentAdd(WEDDING_LIST_ID, 'new_wedding_guests');
    $api->listStaticSegmentMembersAdd(WEDDING_LIST_ID, 'new_wedding_guests', $batch);
    //do I build vars for a campaign?
    $options = array (
      'list_id' => WEDDING_LIST_ID, //What value id's my list segment?
      'subject' => 'Alpha testing.',
      'from_email' => 'wedding@juicywatermelon.com',
      'from_name' => 'Pam & Kellzo',
      'to_name' => $account->name,   
    );

From here can I use a basic campaign and send it?

    $content['text'] = "Some text.";
    $content['html'] = get_link($account);
    $cid = $api->campaignCreate('regular', $options, $content); 
    $result = $api->campaignSendNow($cid);

I'm not sure if I'm understanding the api documentation correctly. I also tried 'list_id' => 'new_wedding_guests'; which failed to create a campaign.

Thanks!


I'll assume this is test code and just make the cursory mention of how you probably don't need to be creating a new Static Segment every time. However, your call to add members is not going to work. Per the listStaticSegmentMembersAdd documentation, you should be passing the static segment id, not the name of it. Also note that the docs cross-reference themselves when input params can come from other calls - that parameter there is a good example (it also happens to be returned by listStaticSegmentAdd).

Your options for campaignCreate look like a good start. The documentation for it has examples below - those examples are included in the PHP MCAPI wrapper you likely downloaded. As per above, the list_id you need is the one for the list you used in the listStaticSegment calls (also linked in the documentation).

Now the real key - further down in the campaignCreate docs is the segment_opts parameter - that is how you control segmentation. Follow the link it gives you and you'll find tons of info on the ways you can do segmentation, including using a static_segment.

Hopefully all of that made sense, if not, take a step back and check out these links (and play with segmentation in the app), then it should:

Introduction to MailChimp List Management

How can I send to a segment of my list?

Our Release Info on how Static Segments are used

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜