drewm / mailchimp-api

Super-simple, minimum abstraction MailChimp API v3 wrapper, in PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

New tags feature

prema770 opened this issue · comments

Thanks very much for the API - it's working very well for us. Is there any intention to add the new tags feature - replacing segments?
Does anyone know ho to do this

Hi!
I also would appreciate to know about it.
Thanks in advance.

Can you post the URL of the part of the MailChimp API you're talking about?

I don't see what specific support you'd need in order to use that part of the API. What am I missing?

I just saw you ask for the part of the API so I answered. Looking at your docs, would this be the syntax to include tags?

$list_id = 'b1234346';
$subscriber_hash = $MailChimp->subscriberHash('davy@example.com');

$result = $MailChimp->patch("lists/$list_id/members/$subscriber_hash", [
'merge_fields' => ['FNAME'=>'Davy', 'LNAME'=>'Jones'],
'tags' => ['name' => 'Houston', 'status' => 'active'],
]);

print_r($result);

Actually, that syntax did not work.... I'm having trouble applying the tags... has anyone else figured out the correct syntax?

OK, figured it out...

$list_id = 'b1234346';
$subscriber_hash = $MailChimp->subscriberHash('davy@example.com');

$result = $MailChimp->post("lists/$list_id/members/$subscriber_hash/tags", [
'tags' => [
[
'name' => 'Houston',
'status' => 'active'
],
[
'name' => 'New Customer',
'status' => 'active'
]
]);

print_r($result);

Will return 1 if successful, an array of information if an error

@emmitt22991 - this worked for me as well!

Great, looks like it's working so I'll close this.

In case any one else finds this, this also works (because 'tags' & 'segments' have the same API endpoint)
https://developer.mailchimp.com/documentation/mailchimp/reference/lists/segments/members/

$addToSegment = $MailChimp->post("lists/{{LISTID}}/segments/{{SEGMENTID}}/members/", [
    "email_address" => "{{EMAIL}}"
]);

I stumbled across this again, ended up using emmitt22991's solution as it seemed impossible to find the 'SEGMENTID' of a static segment (tag)