MailChimp API 3.0 batch/bulk subscribe

2019-02-16 00:02发布

For MailChimp API 2.0 there was a method 'batch-subscribe', to send in an array of email addresses to be added to a specific list in MailChimp.
How to implement this in the new Rest Architecture based MailChimp API 3.0?
See https://github.com/mailchimp/APIv3-examples/wiki/Overview
It says it would work with array of objects
But by the schema it only accepts an object
Schema https://us9.api.mailchimp.com/schema/3.0/Lists/Members/Collection.json

4条回答
走好不送
2楼-- · 2019-02-16 00:48

MailChimp API v3.0 is now live! and they've also added a better batch operations feature which lets you make multiple operations in just one call. You can use below code with the help of this php wrapper for MailChimp apiV3 for the batch operations.

    $data1 =array(
            'email_address' => 'testingmail1@gmail.com',
            'status' => 'subscribed',
            'merge_fields' => array('FNAME' => 'Testing', 'LNAME' => 'Mail1'));
    $data2 =
        array(
            'email_address' => 'testingmail2@example.com',
            'status' => 'subscribed',
            'merge_fields' => array('FNAME' => 'Testing', 'LNAME' => 'Mail2'));
    $attributes = array(
        'operations' => array(
            array(
                'path' => 'lists/' . $listID . '/members',
                'method' => 'POST',
                'body' => json_encode($data1)
            ),
            array(
                'path' => 'lists/' . $listID . '/members',
                'method' => 'POST',
                'body' => json_encode($data2)
            ),
        ));

    $response = $MailChimp->post('batches/', $attributes);
查看更多
一夜七次
3楼-- · 2019-02-16 00:52

Yeah. It was an issue at the Mailchimp end. We reported it and they got it fixed in a day or so.

查看更多
男人必须洒脱
4楼-- · 2019-02-16 01:03

The page you're linking to look like docs from the beta, but either way, they say that batch operations aren't yet implemented. FWIW, the real docs also list Batch Operations as a part of the roadmap, so I doubt they're done yet.

查看更多
聊天终结者
5楼-- · 2019-02-16 01:04

This is not an issue at the Mailchimp end. You just need to use arrays and objects properly.

Good batch subscribe example you can find here https://rudrastyh.com/wordpress/wp-users-to-mailchimp-list.html#batch_subscribe_php

查看更多
登录 后发表回答