Ho provato a fare riferimento a una delle risposte su StackOverflow per creare un nuovo membro in un elenco che attualmente possiedo. Sto cercando di utilizzare l'API v3.0. Di seguito è riportato il codice.Mailchimp cURL Errore "Aggiungi membro"
$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');
Ecco la risposta di errore che sto ricevendo:
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"}"
aiuto è molto apprezzato :)
Grazie, Mihir.
Quasi due anni dopo, e questo mi ha aiutato. Grazie – TheNoob
La stessa cosa che mi ha accaduto l'OP, ma questa risposta non ha funzionato per me, anche se uso l'id dell'elenco corretto. – Ionut
Oltre all'ID elenco, verificare l'URL. Dovrebbe avere .api. NON .admin. nell'indirizzo https: //us1.api.mailchimp.com/3.0/lists/... – DarthRez