سؤال

How can I check if a user (email address) is in a specific list with mailchimp api V2.0?

If is not I want to subscribe the use.

Im using codeigniter but this is irelevant, I'm searching for specific 2.0api function which can do the trick.

هل كانت مفيدة؟

المحلول

here is somthing i use in laravel,

this will search the list for the member ,if found it will update his info (in this case his email) else it will create a new one.

public function update_subscribe($old_email, $new_email, $user)
    {
        $found = MailchimpWrapper::helper()->searchMembers($old_email, $list_id);
        extract($found);

        if ($exact_matches['total'] == 1)
        {
            return MailchimpWrapper::lists()->updateMember(
                $list_id,
                ['email' => $old_email],
                ['new-email' => $new_email],
                'html',
                false
            );
        }
        return $this->add_subscribe($user);
    }

check https://apidocs.mailchimp.com/api/2.0/helper/search-members.php , https://apidocs.mailchimp.com/api/2.0/lists/subscribe.php , https://apidocs.mailchimp.com/api/2.0/lists/update-member.php

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top