[英]Disable double opt-in in Mailchimp api 3.0 using PHP
我在這里和其他幾個站點上閱讀了多個主題。 他們都說,要禁用雙重加入功能,我需要將用戶注冊為“已訂閱”。 那沒用。 這是我的代碼:
$data = [
'email' => $_GET['email'],
'status' => 'subscribed'
];
syncMailchimp($data);
static function syncMailchimp($data) {
$apiKey = 'XXXXXXXXXXX-us3';
$listId = 'XXXXXXXXXX';
$memberId = md5(strtolower($data['email']));
$dataCenter = substr($apiKey,strpos($apiKey,'-')+1);
$url = 'https://' . $dataCenter . '.api.mailchimp.com/3.0/lists/' . $listId . '/members/' . $memberId;
$json = json_encode([
'email_address' => $data['email'],
'status' => $data['status'], // "subscribed","unsubscribed","cleaned","pending"
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERPWD, 'user:' . $apiKey);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return $httpCode;
}
當我嘗試從帳戶中禁用雙重選擇加入功能時,該功能已顯示為灰色,並且不會讓我取消選中它:
如果您有任何想法,我很想聽聽。 謝謝!
聽起來MailChimp帳戶可能處於合規狀態。 有時,這可能要求列表為雙重加入模式。 我將登錄該帳戶,並在右上角查找是否有這種情況的任何通知。
希望這會有所幫助!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.