我在尝试从现有用户添加/更新标签时遇到一些问题。
当我更新现有成员信息时,它不会更新标签(使用方法“ PATCH”)。它更新所有字段,但不更新标签。当我在列表中创建新成员时(使用方法“ POST”),它的确创建了标签。
我正在使用的代码是:
function add_suscriber($data)
{
//Data Format:
//$data = array(
//'apikey' => $api_key,
//'listid' => $list_id,
//'email_address' => $email,
//'status' => $suscripcion,
//'tags' => array($tags),
//'merge_fields' => array(
// 'FNAME' => $nombre, //nombre
// 'LNAME' => $apellido, //apellido
// 'PAIS' => $pais //pais de residencia
// )
//);
$API_URL = 'https://' . substr($data['apikey'],strpos($data['apikey'],'-') + 1 ) . '.api.mailchimp.com/3.0/lists/' . $data['listid'] . '/members/' . md5(strtolower($data['email_address']));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $API_URL);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Basic '.base64_encode( 'user:'.$data['apikey'] )));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data) );
$result = curl_exec($ch);
curl_close($ch);
$response = json_decode($result);
}
有了这个,当它是新用户时,我没问题;但是如果用户已经存在(在任何受众群体中),则所有内容都会更新,但不会更新标签。
谢谢您的帮助!
我正面临着同样的问题,您设法解决了吗?