Closed n3rotech closed 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?
Nevermind - I got it sorted :)
@snipe got sort of the same error. Care to elaborate on how you got it sorted? Thanks
@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) {
}
}
}
@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.
In retrospect, that sounds right. I'm glad you got it sorted
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](https://f.cloud.github.com/assets/6994746/2482322/9f98c762-b0e9-11e3-8c22-6e3496bf6a25.PNG)