我想向 mailchimp 列表中的特定用户添加标签
$email = "toto@example.com";
$tag="test";
$userid = md5( strtolower( $email ) );
$data = array(
'apikey' => $mailchimp_api_key,
'email_address' => $email,
'tags' => array(
'name' => $tag,
'status' => 'active'
)
);
$json_data = json_encode($data);
$url = 'https://'.$mailchimp_datacenter.'api.mailchimp.com/3.0/lists/'.$mailchimp_list_id.'/members/' . $userid . '/tags';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
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);
if ($displaytaglist!="") {
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result …Run Code Online (Sandbox Code Playgroud)