Subscribe to PHP Freaks RSS

Pineco.de: Subscribing Users to a MailChimp List with Laravel and Guzzle

syndicated from www.phpdeveloper.org on October 8, 2018

On the Pineco.de blog they've posted a tutorial showing how to use Guzzle to subscribe users to a Mailchimp mailing list in a Laravel application. The technique isn't specific to a Laravel application and can be adapted relatively easily for other framework/application types.

Managing users and mailing lists are not a that painful nowadays. Since we have excellent services that can cover all the needs we have, we don’t need to worry about it too much. But still, let’s take a look at how can we handle user subscriptions when Laravel fires different events.

In the tutorial, the request is sent to Mailchimp via the user registration event fired when a new user signs up for the site. They include the code to create the listener and register it in the Laravel configuration. They've also included the code that will be used when the event is fired, sending a message to the Mailchimp API with a "subscribed" status and the user information.