如何通过PHP调用Mailchimp API 3.0禁用双重选择加入?
I've scoured through numerous forum posts and websites, all stating that setting a user's status to "subscribed" via the Mailchimp API should bypass double opt-in. But unfortunately, this method isn't working for me at all.
Here's the PHP code I'm using to sync users to Mailchimp:
$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; }
To make matters worse, when I try to disable double opt-in directly in my Mailchimp account settings, the option is grayed out and I can't uncheck it:
Screenshot Context: The "Double opt-in" checkbox in my list's signup form settings is locked (gray) with a checkmark, and there's no way to toggle it off.
I'm really stuck here—could anyone please help me figure out a solution to disable double opt-in? Thanks a ton!
内容的提问来源于stack exchange,提问作者Avi

