MailChimp API integration
Permalink
Hi all,
Having an issue in developing a way to directly add users to a MailChimp list.
Using the following:
adduser.php which is placed in the theme folder
Then using a popup form like this:
However, get a server 500 error when you try and submit the form. I have looked and played around with the permissions for adduser.php to no avail.
Any pointers much appreciated.
Having an issue in developing a way to directly add users to a MailChimp list.
Using the following:
adduser.php which is placed in the theme folder
<?php // include the mailchimp php api files that you downloaded include('Mailchimp.php'); $api_key = "api key"; //replace with your API key $list_id = "listid"; //replace with the list id you're adding the email to // set up our mailchimp object, and list object $Mailchimp = new Mailchimp( $api_key ); $Mailchimp_Lists = new Mailchimp_Lists( $Mailchimp ); $email = 'my@emailaddress.co.uk'; //replace with a test email try { $subscriber = $Mailchimp_Lists->subscribe( $list_id, array( 'email' => $email ) ); //pass the list id and email to mailchimp } catch (Exception $e) { //You'll need to write your own code to handle exceptions } // check that we've succeded
Viewing 15 lines of 19 lines. View entire code block.
Then using a popup form like this:
<?php defined('C5_EXECUTE') or die("Access Denied."); ?> <form role="form" method="post" id="subscribe"> <input type="email" id="email" name="email" placeholder="you@yourself.com" value=""> <button type="submit">SUBSCRIBE</button> </form> <script> $(document).ready(function() { $('#subscribe').submit(function() { if (!valid_email_address($("#email").val())) { $(".message").html('The email address you entered was invalid. Please make sure you enter a valid email address to subscribe.'); } else
Viewing 15 lines of 42 lines. View entire code block.
However, get a server 500 error when you try and submit the form. I have looked and played around with the permissions for adduser.php to no avail.
Any pointers much appreciated.