【发布时间】:2016-07-01 23:54:51
【问题描述】:
我按照 Drewm/Mailchimp API 将自定义表单集成到 Mailchimp 中。
我已成功将用户订阅到我的列表。但是当我包含订阅组代码行时,整个功能不起作用,甚至订阅列表也不起作用了。
但是当我删除订阅组时,订阅列表又可以工作了。
这是我的代码:
include 'MailChimp.php';
$MailChimp = new \Drewm\MailChimp('ab4dc1be0f31933f5f8bcdc82231a47d-us4');
$result = $MailChimp->call('lists/subscribe', array(
'id' => '0c043be204',
'email' => array('email'=>$email),
'merge_vars' => array('FNAME'=>$firstname, 'LNAME'=>$lastname),
// 'groupings' => array(
// array(
// 'id' => 19361,
// 'groups' => array($_POST['group'])
// )
// )
// ),
'double_optin' => false,
'update_existing' => true,
'replace_interests' => false,
'send_welcome' => false,
));
print_r($result);
我的 HTML 表单如下所示:
<div class="col-md-6">
<label>Email Address</label><br>
<input name="Email" type="email" required="required" id="Email" placeholder="Email">
<label>First Name</label><br>
<input name="FirstName" type="text" required="required" id="FirstName" placeholder="First Name">
<label>Last Name</label><br>
<input name="LastName" type="text" required="required" id="LastName" placeholder="Last Name">
<div id="group">
<label>Areas of Interest</label><br>
<input name="group[]" type="checkbox" id="Interest1" class="interest"><label>Turf</label><br>
<input name="group[]" type="checkbox" id="Interest2" class="interest"><label>Landcare</label><br>
<input name="group[]" type="checkbox" id="Interest3" class="interest"><label>Landscaping</label><br>
<input name="group[]" type="checkbox" id="Interest4" class="interest"><label>Landscaping Architects</label><br>
<input name="group[]" type="checkbox" id="Interest5" class="interest"><label>Nurseries</label>
</div>
我不知道我缺少什么或代码有什么问题。希望可以有人帮帮我。谢谢!
【问题讨论】:
-
您从 API 收到什么错误?
-
没有错误。它只是没有做它应该做的事情。当我运行上面的代码时,它工作正常。但是当我删除评论时,删除“$lastname”上的“)”然后它就不再起作用了。
-
“不起作用”是什么意思?就像它根本不订阅用户一样?您从 MailChimp 收到的响应的实际正文是什么?
-
是的,当我包含注释代码时,它不会订阅用户。 Mailchimp 也没有任何回应。