简体   繁体   English

Mailchimp API v2

[英]Mailchimp API v2

Could someone help me to show what i'm missing? 有人可以帮我展示我所缺少的吗?

I would register subscribers by the PHP mailchimp API. 我将通过PHP mailchimp API注册订户。 I used this example https://github.com/mailchimp/mcapi2-php-examples . 我使用了这个示例https://github.com/mailchimp/mcapi2-php-examples

I copied the composer json file to get the API. 我复制了composer json文件以获取API。 And, i used the lists controller to get info and push subscribers to mailchimp (ex : https://github.com/mailchimp/mcapi2-php-examples/blob/master/Controller/ListsController.php ) 而且,我使用列表控制器获取信息并将订户推送到mailchimp(例如: https : //github.com/mailchimp/mcapi2-php-examples/blob/master/Controller/ListsController.php

try {

            $this->mc = new Mailchimp(Settings::get('mailchimp_api_key'));
            $lists = $this->mc->lists->getList();

            foreach ($lists['data'] as $list) {
                $this->mc->lists->subscribe(
                  $list['id'],
                  array(
                    'email' => $email
                  )
                );
            }
        }
        catch (Mailchimp_Error $e) {
            if ($e->getMessage()) {
                log_message('error', 'mailchimp : ' . $e->getMessage());
            }
            else {
                log_message('error', 'mailchimp : error');
            }
        }

Like this i would add subscribers to every lists i have on mailchimp. 这样,我会将订户添加到mailchimp上的每个列表中。

On mailchimp interface, i got my api key (correspond to Settings::get('mailchimp_api_key') in code). 在mailchimp界面上,我得到了我的api密钥(与代码中的Settings :: get('mailchimp_api_key')相对应)。 In mailchimp lists i added a "test" list (us8.admin.mailchimp.com/lists/). 在mailchimp列表中,我添加了一个“测试”列表(us8.admin.mailchimp.com/lists/)。

But nothing happend.. Do you see what i'm missing? 但是什么也没发生。.你看到我所缺少的吗?

Mailchimp has four flags, one flag is "double_optin" by default it is set to true. Mailchimp有四个标志,一个标志默认为“ double_optin”,它设置为true。 So when you subscribed the user to list the api return msg "Successfully subscribed" but when you check in list the user is not there in the list, for that you have to check the email and confirm user subscription for that list then user will appear to that list. 因此,当您订阅该用户以列出api时,返回msg“已成功订阅”,但是当您签入列表时,该用户不在列表中,为此,您必须检查电子邮件并确认该列表的用户订阅,然后该用户才会出现到那个清单。 So you will have to change the flag from "true" to "false". 因此,您必须将标志从“ true”更改为“ false”。

Thanks 谢谢

I know that you have to confirm e-mail subscriptions from the e-mail that MailChimp sends out. 我知道您必须从MailChimp发送的电子邮件中确认电子邮件订阅。 Check those e-mails, including spam, so see if you at least got that. 检查那些电子邮件,包括垃圾邮件,因此至少看看您是否明白。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM