MailChimp API 3.0 batch/bulk subscribe

后端 未结 4 811
花落未央
花落未央 2021-01-07 11:57

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 i

4条回答
  •  一生所求
    2021-01-07 12:26

    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);
    

提交回复
热议问题