pacely/mailchimp-api-v3

POST Request

banago opened this issue · 3 comments

Hi @ChrisRM,

Thanks for putting this together - very handy.

I'm trying to run a POST request, but seems I cannot get my arguments right. The GET request works fine:

$lists = $mc->request('lists/{list_id}/members', [
    'fields' => 'members.email_address,members.status',
    'count' => 30
]);

How would it look at as a POST request. I want to subscribe an email programmatically. Thanks very much!

Hi @banago,

The request method takes 3 arguments: request($resource, $arguments = [], $method = 'GET').

Adding a subscriber can be done like this:

// Replace <list_id> with your list id.
$subscriber = $mc->request('lists/<list_id>/members', [
    'email_address' => 'your@subscriber.com',
    'status' => 'subscribed'
], 'post');

I did try that one a lot more, but it always produces an error. I need to know who to build the $arguments array for posting. The rest is clear.

See my updated response above, @banago. Make sure you pull down the latest version.