hugofirth / laravel-mailchimp

A composer package for the MailChimp API PHP class (as provided by MailChimp) which supports the Laravel 4 framework.
96 stars 27 forks source link

Class "MailchimpWrapper" not found while use Unsubscribe #13

Closed n3rotech closed 10 years ago

n3rotech commented 10 years ago

i was wonder why get "class MailchimpWrapper" not found in phpunit if try to unsubscribe. (note: i have set Provider and Aliases, run composer dump-autoload). Thank you error class mailchimpwrapper

snipe commented 10 years ago

I'm having a similar problem:

if (Input::get('newsletter')=='1') {
        \Hugofirth\Mailchimp\MailchimpServiceProvider\MailchimpWrapper::lists()
        ->subscribe(
        'XXXXX', array(
        'email' => $user->email_address),
        array(
            'FirstName' => $user->first_name,
            'LastName' => $user->last_name)
        );
    } else {
        // Hugofirth\Mailchimp\MailchimpServiceProvider
        \Hugofirth\Mailchimp\MailchimpServiceProvider\MailchimpWrapper::lists()
        ->unsubscribe('XXXX',
            array(
            'email' => $user->email_address)
            );
}

Returns:

Symfony \ Component \ Debug \ Exception \ FatalErrorException Class 'Hugofirth\Mailchimp\MailchimpServiceProvider\MailchimpWrapper' not found

But it's only triggering this error on the unsub. Any ideas?

snipe commented 10 years ago

Nevermind - I got it sorted :)

MaartenW commented 9 years ago

@snipe got sort of the same error. Care to elaborate on how you got it sorted? Thanks

snipe commented 9 years ago

@MaartenW Honestly, I'm not sure I remember, it was a few months ago. I can show you the code that is working for me now tho. It may not be helpful, since I don't remember what I changed, but it's the best I can do.

// if they have checked the newsletter box
    if (Input::get('newsletter')) {

        // and they are not already subscribed
        if ($subscribed_status == 0) {

        // subscribe them
        try
            {
                MailchimpWrapper::lists()
                ->subscribe(
                'XXX', array(
                'email' => $user->email),
                array(
                    'FNAME'             => $user->first_name,
                    'LNAME'             => $user->last_name,
                    'update_existing'   => true,
                    'send_welcome'      => false,
                    'double_optin'      => false,
                    )
                );
                $subscribed_status = 1;
            } catch (Exception $e) {

            }

        }

    } elseif ($pending!=1) {

        // If they unchecked the subscribe box, and they were previously subscribed, unsubscribe them
        if ($subscribed_status==1) {

            try
            {
                MailchimpWrapper::lists()
                ->unsubscribe('XXX',
                    array(
                    'email'         => $user->email)
                    );
                $subscribed_status = 0;

            } catch (Exception $e) {

            }
        }

    }
MaartenW commented 9 years ago

@snipe thanks. Your comment sent me in the right direction. For me it all had to do with caps... Followed a tut which was mixing up caps and non-caps.

snipe commented 9 years ago

In retrospect, that sounds right. I'm glad you got it sorted