【发布时间】:2017-06-11 02:43:46
【问题描述】:
我正在尝试将电子邮件订阅到 PHP 中的 MailChimp 列表。我实际上不是后端开发人员,所以我在这方面停滞不前:(
我正在使用 MailChimp 辅助 PHP 库:https://github.com/drewm/mailchimp-api
我已经搜索了所有互联网,我只能得到 500 内部服务器错误的状态。我已经在生产服务器中了。
<?php
include("./inc/MailChimp.php");
use \DrewM\MailChimp\MailChimp;
$api_key = "xxxxxxxxxxx-us13";
$list_id = "7xxxxxxx4";
$MailChimp = new MailChimp($api_key);
$result = $MailChimp->post("lists/$list_id/members", [
"email_address" => $_POST["txt_mail"],
'merge_fields' => ['FNAME'=>$_POST["txt_name"], 'FPHONE'=>$_POST["txt_phone"], 'FMSG'=>$_POST["txt_message"]],
"status" => "subscribed"
]);
if ($MailChimp->success()) {
echo "<h4>Thank you, you have been added to our mailing list.</h4>";
} else {
echo $MailChimp->getLastError();
} ?>
【问题讨论】:
-
这在 12 月被废弃,现在你必须使用
CURL才能使用 3.0。看我的回答:) -
您需要通过查看服务器日志找出导致
500错误的原因,我的猜测是您使用的 PHP 版本低于 5.4 并且您的数组需要语法从[]固定到array()
标签: php mailchimp mailchimp-api-v3.0