以订阅格式

时间:2018-04-01 22:42:11

标签: forms email mailchimp subscribe

我的订阅表格没什么问题。我已将此代码用于HTML页面:

<form action="subscribe.php" id="subscribe" method="post" name="subscribe1">
                                                <input style="" class="subscribe-requiredField subscribe-email" id="" name="subscribe-email" placeholder="Email" type="text">
                                                <a style="" href="#"><button class="submit-button-2 rimu1 rimu2" id="submit-2" type="submit">Subscribe</button></a> 
                </form>

这是来自 subscribe.php 的代码:

<?php


require_once 'mailchimp/inc/MCAPI.class.php';
// MailChimp API Key
// MailChimp API Key ARTICLE at http://kb.mailchimp.com/accounts/management/about-api-keys#Finding-or-generating-your-API-key
$api = new MCAPI('04e62f3fa3d9bdd51XX8cd939b1abee8-usXXX');
$merge_vars = array();

// MailChimp List ID
// MailChimp List ID ARTICLE at http://kb.mailchimp.com/lists/managing-subscribers/find-your-list-id
$retval = $api->listSubscribe( '3fc8c08XXX', $_POST["subscribe-email"], $merge_vars, 'html', false, true );

&GT;

将邮件输入表单后,获取白屏,并且不发送邮件。有人可以帮我解决这个问题吗? Example可以在这里看到。感谢

1 个答案:

答案 0 :(得分:1)

嘿我正在使用https://github.com/drewm/mailchimp-api mailchimp api,它非常简单它可以像这样简单地完成:

require_once 'class/MailChimp.php';
$MailChimp = new MailChimp($mc{'key'});


$result = $MailChimp->post("lists/$AddToListId/members", [
                'email_address' =>$email,
                'status'        => 'subscribed'
        ]);
在库中BTW你只使用前两个参数是必要的,它们可以省略而不是作为假人传递