我試着引用StackOverflow上的一個答案來在我目前擁有的列表中創建一個新成員。我正在嘗試使用API v3.0。以下是代碼摘錄。Mailchimp cURL「添加成員」錯誤
$apikey = 'api_key_here';
$auth = base64_encode('user:'.$apikey);
$data = array(
'apikey' => $apikey,
'email_address' => '[email protected]',
'status' => 'subscribed',
'merge_fields' => array(
'FNAME' => 'Mihir'
)
);
$json_data = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://us2.api.mailchimp.com/3.0/lists/my_list_id_here/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);
var_dump($result);
die('Mailchimp executed');
以下是錯誤回答我收到:
string(218) "{"type":"http://kb.mailchimp.com/api/error-docs/404-resource-not-found","title":"Resource Not Found","status":404,"detail":"The requested resource could not be found.","instance":"f03f3b5d-ef59-4452-b502-8a96449025df"}"
幫助是非常讚賞:)
感謝, 米希爾。
幫我。謝謝 – TheNoob
同樣的事情發生在我身上,但這個答案對我來說不起作用,即使我使用了正確的列表ID。 – Ionut
除了列表ID之外,請驗證您的網址。它應該有.api。 NOT .admin。在地址中。 https://us1.api.mailchimp.com/3.0/lists/... – DarthRez