mailchimp-api icon indicating copy to clipboard operation
mailchimp-api copied to clipboard

Can this library be used for export API?

Open ghost opened this issue 7 years ago • 4 comments

can this library be used with MailChimp's export api? https://developer.mailchimp.com/documentation/mailchimp/guides/how-to-use-the-export-api/

is it the same as the api implementation?

ghost avatar Apr 29 '18 00:04 ghost

I have the same question.

crossan007 avatar Sep 07 '18 02:09 crossan007

I think, you are simply using the MailChimp instance like this

$mailChimp = new MailChimp($apiKey, https://<dc>.api.mailchimp.com/export/1.0/);
$result = $mailChimp->post('list');

Maybe it will be necessary to adapt the return according to the format that is returned. Can you try and make a feedback please ?

maxhelias avatar Sep 29 '18 17:09 maxhelias

Did you folks conclude if this was possible? I've not used at the export API, so haven't tried it myself.

drewm avatar Aug 15 '19 11:08 drewm

It works, if you override some stuff but the response is empty because MC sends a series of JSON objects separated by \n which formatResponse() rightfully does not expect.

$this->api = new MailChimp(MAILCHIMP_API_KEY, 'https://'.MAILCHIMP_DC.'.api.mailchimp.com/export/1.0');
$ret = $this->api->get('list/', [
	'apikey' => MAILCHIMP_API_KEY, /* REQUIRED PARAMETER */
	'id' => $this->id_list,
	'status' => $status,
	'hashed' => 'sha256'
], 60);

Output snippet:

["EMAIL_HASH"] 
["e30290504178be7dd98f2365195e866473c709c4c50fb6ad7829238459cad685"] 
["5b67a4f61804e8fca866ede6753fcdb25312039798fc004e1383f9e698792925"]

I suppose it would be necessary to add a case to the construct for <dc> and especially enhance the formatter. Or have a raw response option and let the user deal with it.

EDIT: The API returns a stream so more changes would be necessary. I am just Guzzling it for now.

tucoinfo avatar Apr 12 '20 17:04 tucoinfo