Code Monkey home page Code Monkey logo

hominid's Introduction

Hominid

Hominid is a GemPlugin wrapper to the Mailchimp API.

Installation

There are a few options for installing Hominid.

Install as a Rails plugin:

script/plugin install git://github.com/bgetting/hominid.git

Clone from the Github repository:

git clone git://github.com/bgetting/hominid.git

Use the GemPlugin:

config.gem "bgetting-hominid", :lib => 'hominid', :source => "http://gems.github.com"

Configuration

Please note that Hominid expects to find a configuration file at /config/hominid.yml. If you are using Hominid as a GemPlugin, you will need to be sure and create this file. If you are using Hominid as a normal Rails plugin, this file will be created automatically when the plugin is installed. You will need to create a Mailchimp account and put your API key (available at http://admin.mailchimp.com/account/api/) into the configuration file.

Example

To interact with the Mailchimp API, simply create a new Hominid object:

@hominid = Hominid.new

First, locate the mailing list that you are going to be working with. If you know the mailing list ID, then you can use that directly. Or you can find a particular list by name using:


def find_list_id(list_name)
  mailing_lists = @hominid.lists
  unless mailing_lists.nil?
    @list_id = mailing_lists.find {|list| list["name"] == list_name}["id"]
  end
end

For example, to subscribe someone to a mailing list at Mailchimp:

@hominid.subscribe(@list_id, "[email protected]", {:FNAME => 'Bob', :LNAME => 'Smith'}, 'html')

To unsubscribe someone:

@hominid.unsubscribe(@list_id, "[email protected]")

To update a list member:

@hominid.subscribe(@list_id, "[email protected]", {:FNAME => 'Robert', :EMAIL => '[email protected]'}, 'html', true)

or

@hominid.update_member(@list_id, "[email protected]", {:FNAME => 'Robert', :EMAIL => '[email protected]'})

Campaign methods are also supported. You can get all the campaigns for a particular list by:

@hominid.campaigns(@list_id)

Leave the @list_id out and it will return all the campaigns for your Mailchimp account.

Other Stuff

For the most part, this whole thing was an attempt to optimize the acts_as_mailchimp plugin, and incorporates all the great work from C.G. Brown and Kelly Mahan, as well as Matthew Carlson, whose plugin inspired nearly all of this work.

The Acts_As_Mailchimp plugin will be updated to utilize Hominid, so that there is still a way to add simple “acts_as” methods to a model. However, since Hominid is such a thin wrapper I encourage people to start experimenting with using the other methods to integrate newsletter marketing natively into their apps. Mailchimp put a lot of work into their API, so take advantage of it and make something cool!

Copyright © 2009 Brian Getting, released under the MIT license.

hominid's People

Stargazers

 avatar  avatar

Watchers

 avatar  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.