Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Query Parameters to Mailchimp API request for PHP

I am currently following the documentation seen here: https://mailchimp.com/developer/marketing/api/list-members/list-members-info/ Using the PHP example:

$response = $client->lists->getList("list_id");

This returns just fine. But I would like to add in the 'unsubscribed_since' Query Parameter. How do I format the query parameters? I've tried:

$response = $mailchimp->lists->getListMembersInfo("id", array('unsubscribed_since' => '2020-01-01'));

As well as:

$response = $mailchimp->lists->getListMembersInfo("3d65de82df", ['unsubscribed_since' => '2020-01-01']);

Any help would be appreciated.

like image 985
Sean Avatar asked Sep 24 '26 04:09

Sean


2 Answers

I had a similar problem with count parameter. Looking into the code I found the following definition of getListMembersInfo method:

public function getListMembersInfo($list_id, $fields = null, $exclude_fields = null, $count = '10', $offset = '0', $email_type = null, $status = null, $since_timestamp_opt = null, $before_timestamp_opt = null, $since_last_changed = null, $before_last_changed = null, $unique_email_id = null, $vip_only = null, $interest_category_id = null, $interest_ids = null, $interest_match = null, $sort_field = null, $sort_dir = null, $since_last_campaign = null, $unsubscribed_since = null)

Calling the method with the additional parameters solved my problem.

like image 139
fgaleazzi Avatar answered Sep 26 '26 02:09

fgaleazzi


Expanding on Dharman's comment, you would need to use:

$response = $mailchimp->lists->getListMembersInfo("3d65de82df", null, null, '10', '0', null, 'unsubscribed', null, null, null, null, null, null, null, null, null, null, null, null, '2020-01-01');

https://mailchimp.com/developer/marketing/api/list-members/list-members-info/ is not very clear.

like image 43
John Dorner Avatar answered Sep 26 '26 02:09

John Dorner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!