I need an example of how to subscribe a email address to mailchimp newsletter.
Please check new api link here: https://bitbucket.org/mailchimp/mailchimp-api-php
This is new malichimp api and I am not sure how to use it. :(
For MailChimp 2.0 API, not for 1.3.
Please somebody provide an example on how to subscribe user to mailchimp.
Thank You.
Edit1: Already tried following code, but not working:
$merge_vars = array('MM1'=>$mm1);
$MailChimp = new Mailchimp($apikey);
$result = $MailChimp->call('lists/subscribe', array(
'id' => $listid,
'email' => array('email'=>$email),
'merge_vars' => $merge_vars,
'double_optin' => false,
'update_existing' => true,
'replace_interests' => false,
'send_welcome' => false,
));
print_r($result);
But not working. Throwing following error: Fatal error: Call to a member function call() on a non-object in subscribe.php on line 22
Referring to the documentation, this should be like so:
$merge_vars = array('MM1'=>$mm1);
$listid = 'YOURLISTID';
$MailChimp = new Mailchimp($apikey);
$result = $MailChimp->lists->subscribe($listid,
array('email'=>"[email protected]"),
$merge_vars,
false,
true,
false,
false
);
print_r($result);
Tested and working.