Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Hominid is a Ruby gem that provides a wrapper for interacting with the Mailchimp API.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
rails
test
MIT-LICENSE
README.textile
Rakefile
VERSION.yml
hominid.gemspec
hominid.yml.tpl
init.rb
install.rb
uninstall.rb

README.textile

Hominid

Hominid is a GemPlugin wrapper to the Mailchimp API.

Installation

There are a few options for installing Hominid. 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.

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", :version => '~> 0.0.1', :lib => 'hominid', :source => "http://gems.github.com"

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@example.com", {:FNAME => 'Bob', :LNAME => 'Smith'}, 'html')

To unsubscribe someone:

@hominid.unsubscribe(@list_id, "email@example.com")

To update a list member:

@hominid.update_member(@list_id, "email@example.com", {:FNAME => 'Robert', :EMAIL => 'another@example.com'})

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.

Something went wrong with that request. Please try again.