Making an Ajax newsletter sign-up box
One way to have users added to our e-mail list is to have them sign-up through our website. In this recipe, we'll be using MailChimp's API and a modal window to show a sign-up form and have it sent through an Ajax call.
Getting ready
For this recipe, we'll need a standard Laravel installation. We'll also be using the MailChimp API for the newsletter; a free account and API key can be created at www.mailchimp.com.
How to do it…
To complete this recipe, follow the given steps:
Open the
composer.json
file and update therequire
section to resemble the following code:"require": { "laravel/framework": "4.0.*", "rezzza/mailchimp": "dev-master" }
In the command-line window, where the artisan file is located, update Composer with the following command:
php composer.phar update
In the
app/config
directory, create a file namedmailchimp.php
:<?php return array('key' => '12345abcde-us1','list' => '123456789' );
In the
views
directory, create a file named...