简体   繁体   中英

Integrate Mailchimp into Laravel with API

I am new to Laravel and am stuck. I've use the Hugo Firth api wrapper in Laravel for mailchimp. What I can't figure out is where to put this the code in laravel. Does it go on the controller? This is the code for subscribe:

MailChimpWrapper::lists()->subscribe($list_id, array('email' => $email_address));

I also need the list_id..do I put the list ID there or create a variable called $list_id = with my list id? or can I put it right on my landing page?

@section('content')
{{ MailChimpWrapper::lists()->subscribe($list_id, array('email' => $email_address)); }}
<div class="grid">
    <div class="grid-9">

EDIT

public function index()
{
    return View::make('landing/landing');
    MailChimpWrapper::lists()->subscribe('list_id', array('email' => $email_address));
}

You're going to find the list ID in MailChimp. It's more of a static thing, than a variable. I only use 1 list, so it's actually just coded as a string for me.

And it goes in your controller, so this is what I have:

MailchimpWrapper::lists()->subscribe('list_id', ['email' => $email], [
    'FNAME' => $firstname,
    'LNAME' => $lastname
]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM