Hello guys I am trying to update a contact in my list with CRUL. I think everything looks great, only one think that I don't understand is {subscriber_hash}. How can i get this? Or maybe thats not a problem
I get this response
Exists","status":400,"detail":"example@example.com is already a list member. Use PUT to insert or update list members.","instance":"a5de431b-3b5a-3149-1fe3-bc1f6d08ec24"}
But my code looks good i think
$list_id = '[LISTID]';
$authToken = '[APIKEY]';
$postData = array(
"email_address" => "example@example.com",
"status" => "subscribed"
);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://us12.api.mailchimp.com/3.0/lists/'.$list_id.'/members/{subscriber_hash}',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode($postData),
CURLOPT_HTTPHEADER => array(
'Authorization: apikey '.$authToken,
"cache-control: no-cache",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}