Giter VIP home page Giter VIP logo

cakephp-mailchimp's Introduction

Cakephp Plugin for Mailchimp

With this datasource you can easily add users to your Mailchimp newsletter. It works with CakePHP 2.0+.

Please check the original blogpost on our devblog for more background information.

It uses the current API version 1.3 from Mailchimp.

Setup

Copy the plugin into the APP/Plugin folder and make sure it is loaded using CakePlugin::loadAll(), for example.

Add the $mailchimp datasource to APP/Config/database.php

public $mailchimp = array(
	'datasource' => 'Mailchimp.MailchimpSubscriberSource',
	'apikey' => 'YOUR_API_KEY',
	'defaultListId' => 'YOUR_LIST_ID',
);

For BC you can also use the Configure class to set the API data:

$config['Mailchimp'] = array(
	'apiKey' => 'YOUR_API_KEY',
	'defaultListId' => 'YOUR_LIST_ID',
);

Usage

Include the Model where you need it via

$this->MailchimpSubscriber = ClassRegistry::init('Mailchimp.MailchimpSubscriber');

When you've set the datasource up correctly, you will now be able to do stuff like $this->MailchimpSubscriber->save($this->request->data), or call other regular Model methods (like Model::find) from any controller that uses the MailchimpSubscriber model.

Debugging

Unfortunately, the 1.3 vendor class from Mailchimp does not through exceptions. So if your methods return false and you need to know the error message/code you will have to use the following:

debug($this->MailchimpSubscriber->Mailchimp->errorCode);
debug($this->MailchimpSubscriber->Mailchimp->errorMessage);

with $this->MailchimpSubscriber being your model.

Dependencies

Possibly my Tools plugin for the admin backend (optional)

Disclaimer

MIT Licence

Modified 2012 Mark Scherer: added tests + some basic admin backend and made it a plugin

cakephp-mailchimp's People

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.