希望得到一些帮助,因为在任何地方都找不到答案。
我正在使用以下 PHP 函数将订阅者添加到 mailchimp。这工作正常。我需要做的是添加分配了一个或多个组兴趣的用户。例如,我有一个名为“测试组”的组,其中包含两个兴趣“测试 1”和“测试 2”。我将如何修改以下函数以包含 1 个或多个兴趣值?
function mc_subscribe($email, $fname, $lname, $apikey, $listid, $server) {
$auth = base64_encode( 'user:'.$apikey );
$data = array(
'apikey' => $apikey,
'email_address' => $email,
'status' => 'subscribed',
'merge_fields' => array(
'FNAME' => $fname,
'LNAME' => $lname
)
);
$json_data = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://'.$server.'api.mailchimp.com/3.0/lists/'.$listid.'/members/');
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_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
$result = curl_exec($ch);
return $result;
};