我刚刚在MailChimp网站上阅读了以下内容:
MailChimp API v3.0现已发布!2016年之后将不再支持以前的版本,因此所有API用户都应开始过渡到v3.0。
因此,我想转到API的v3.0。请让我在PHP中有一个返回布尔值的函数,该函数将检查电子邮件地址是否已订阅特定的MailChimp列表。我不想订阅该用户,而只是检查他们是否已订阅。
更新:我用关于如何使用jQuery的更详尽的教程回答了另一个问题.ajax()
:使用Mailchimp的API v3将订阅者添加到列表中
查看Mailchimp文档,并假设您已经有了一个给定的列表,看起来您将使用GET来调用此终结点:/lists/{list_id}/members/{subscriber_hash}
为此,我在github上找到了一个不错的脚本。他们的最后一个功能可能会帮您解决问题:
function mc_checklist($email, $debug, $apikey, $listid, $server) {
$userid = md5($email);
$auth = base64_encode( 'user:'. $apikey );
$data = array(
'apikey' => $apikey,
'email_address' => $email
);
$json_data = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://'.$server.'.api.mailchimp.com/3.0/lists/'.$listid.'/members/' . $userid);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',
'Authorization: Basic '. $auth));
curl_setopt($ch, CURLOPT_USERAGENT, 'PHP-MCAPI/2.0');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
$result = curl_exec($ch);
if ($debug) {
var_dump($result);
}
$json = json_decode($result);
echo $json->{'status'};
}
如果该功能不起作用,则可以为v3库找到的唯一包装器与Laravel- Mailchimp v3 API PHP包装器结合使用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句