Mailchimp API在生产时调用错误代码500

时间:2015-03-19 08:49:06

标签: php jquery ajax curl mailchimp

我创建了一个单页网站,您可以在其中订阅Mailchimp上的新闻通讯列表。订阅是使用Ajax进行的,调用php脚本,然后使用MailChimp php api将订阅者添加到列表中。

奇怪的是,它正在我的localhost xampp环境中工作,但不在生产服务器上?它可能是与Curl相关的东西吗?

我已经检查过Curl已经启用了,所以我对这个有点无能为力。

错误:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

jQuery的:

                $.ajax({
                    url: 'ajax/Newsletter.php',
                    data: {
                        email: $("#mce-EMAIL").val()
                    },
                    dataType: 'json',
                    type: 'POST',
                    success: function (msg) {
                        hideSpinner();
                        if (msg == "success") {
                            $("#mce-EMAIL").val("");
                            showAlert("Success!", "You have successfully subscribed to our mailing list", "success", "OK");
                        } else {
                            showAlert("Oops...", "The email address you entered was invalid. Please make sure you enter a valid email address to subscribe.", "error", "OK");
                        }
                    },
                    error: function (jqXHR) {
                        hideSpinner();
                        console.log(jqXHR);
                        showAlert("Oops...", "Something went wrong. Please try again later!", "error", "OK");
                    }
                });

Newsletter.php:

<?php
require("../includes/MailChimp.php");
require("../includes/Config.php");
$api_key = API_KEY;
$list_id = LIST_ID;

$Mailchimp = new Mailchimp($api_key);
$Mailchimp_Lists = new Mailchimp_Lists($Mailchimp);
$subscriber = $Mailchimp_Lists->subscribe($list_id, array('email' => htmlentities($_POST['email'])), null, 'html', false);
sleep(1);

if (!empty($subscriber['leid'])) {
    echo json_encode("success");
} else {
    echo json_encode("fail");
}

0 个答案:

没有答案