drewm / mailchimp-api

Super-simple, minimum abstraction MailChimp API v3 wrapper, in PHP
MIT License
1.99k stars 505 forks source link

Batch Patch request #293

Open B33T opened 4 years ago

B33T commented 4 years ago

Hello, Any chance you could update the docs with a batch patch request, I cannot seem to make it function.

I am using this

$subscriber_hash = MailChimp::subscriberHash($email); $thebatchname = "op".$batchno; $result = $Batch->patch("$thebatchname","lists/$list_id/members/$subscriber_hash", [ 'merge_fields' => ['FNAME'=>"$first_name", 'LNAME'=>"$last_name"], 'status' => "$subscriber", ]); $batchno = $batchno +1;

Array ( [id] => 7a6a1780a6 [status] => pending [total_operations] => 0 [finished_operations] => 0 [errored_operations] => 0 [submitted_at] => 2020-03-20T15:47:37+00:00 [completed_at] => [response_body_url] => [_links] => Array ( [0] => Array ( [rel] => parent [href] => https://us19.api.mailchimp.com/3.0/batches [method] => GET [targetSchema] => https://us19.api.mailchimp.com/schema/3.0/Definitions/Batches/CollectionResponse.json [schema] => https://us19.api.mailchimp.com/schema/3.0/CollectionLinks/Batches.json ) [1] => Array ( [rel] => self [href] => https://us19.api.mailchimp.com/3.0/batches/7a6a1780a6 [method] => GET [targetSchema] => https://us19.api.mailchimp.com/schema/3.0/Definitions/Batches/Response.json ) [2] => Array ( [rel] => delete [href] => https://us19.api.mailchimp.com/3.0/batches/7a6a1780a6 [method] => DELETE ) ) )

the same command with post works perfectly any ideas? or can you elaborate on its usage with the docs? I have stared at this code now for a good few hours with little joy and I swear it's going to be something simple.

PS I know the code is untidy / crap its because I have been messing around for hours attempting to get it going!

B33T commented 4 years ago

This code does work, but oftentimes out because of so many entries

$subscriber_hash = MailChimp::subscriberHash($email) $result = $MailChimp->patch("lists/$list_id/members/$subscriber_hash", [ 'merge_fields' => ['FNAME'=>''.$first_name.'', 'LNAME'=>''.$last_name.''], 'status' => ''.$subscriber.'', ]);