我正在尝试使用mailchimp API将电子邮件添加到列表中。我使用这个代码
// add user to mailchimp newsletter list
function addToMailChimp($email,$fname,$lname){
require_once(get_stylesheet_directory().'/assets/Mailchimp.php');
$apikey = '"xxxxxxxxxx-us7"';
$list_id ="7xxxxxxxe";
$MailChimp = new MailChimp($apikey);
$result = $MailChimp->call('lists/subscribe', array(
'id' => $list_id,
'email' => array('email'=>$email),
'merge_vars' => array('FNAME'=>$fname, 'LNAME'=>$lname),
'double_optin' => false,
'update_existing' => true,
'replace_interests' => false,
'send_welcome' => false,
));
die(var_dump($result));
}
会返回错误:
NetworkError: 500 Internal Server Error -
我不知道如何处理这个问题
我很感激你的帮助
编辑:看到评论,
$apikey = '"xxxxxxxxxx-us7"';
有单引号和双引号,导致错误的API密钥,导致服务器无法进行身份验证并返回500。