check if user is in a list with mailchimp API V2.0

纵然是瞬间 提交于 2019-12-11 09:57:48

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/22527541/check-if-user-is-in-a-list-with-mailchimp-api-v2-0

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!