Welcome Guest, Not a member yet? Register   Sign In
Mailchimp newsletter subscriptions
#3

[eluser]The Wizard[/eluser]
Hello,

this is a quick & dirty integration of mailchimp.

It loops trough the lists in your api key and adds the
email to it.

Hope it is of good use to you.

BTW, i renamed the file MCAPI.class.php to MCAPI.php and put
it into the libraries folder.
Code:
$this->load->library( 'Mcapi', array() );
        



        $apikey = 'HERE GOES YOUR API KEY, DONT FORGET THIS, YES I KNOW THIS WILL CAUSE AN ERROR'
        $this->load->library( 'Mcapi' );

        $api = new MCAPI($apikey);

        $data_lists = $api->lists();

        if ( $api->errorCode )
        {
            echo "Unable to load lists()!";
            echo "\n\tCode=".$api->errorCode;
            echo "\n\tMsg=".$api->errorMessage.'<br />';
        }
        else
        {


            foreach ( $data_lists['data'] as $list )
            {

                // echo "Id = ".$list['id']." - ".$list['name'].'<br />';
                // echo "Web_id = ".$list['web_id'].'<br />';
                // echo "\tSub = ".$list['stats']['member_count'];
                // echo "\tUnsub=".$list['stats']['unsubscribe_count'];
                // echo "\tCleaned=".$list['stats']['cleaned_count'].'<br />';


                $merge_vars = array(
                                    'FNAME'=>'Test',
                                    'LNAME'=>'Account'
                                    );

                // By default this sends a confirmation email - you will not see new members
                // until the link contained in it is clicked!
                $retval = $api->listSubscribe( $list['id'], '[email protected]', $merge_vars );

                if ($api->errorCode){
                    echo "Unable to load listSubscribe()!\n";
                    echo "\tCode=".$api->errorCode."\n";
                    echo "\tMsg=".$api->errorMessage."\n";
                } else {
                    echo "Subscribed - look for the confirmation email!\n";
                }
                


            }


        }


Messages In This Thread
Mailchimp newsletter subscriptions - by El Forum - 07-12-2010, 03:30 PM
Mailchimp newsletter subscriptions - by El Forum - 07-15-2010, 02:30 AM
Mailchimp newsletter subscriptions - by El Forum - 02-26-2011, 02:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB