phpmailchimpmailchimp-api-v3.0

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.


Solution

  • 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.