Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Activeresource wrapper for the Constant Contact API

tree: 902268db8e

Fetching latest commit…

Cannot retrieve the latest commit at this time


This is a very ActiveResource-like ruby wrapper to the Constant Contact API. It's not quite done yet and if you are interested in using this code, check it out, and message me with questions.

See the ActiveResource::Base docs for more information on how to use this ActiveResource-based wrapper.


All examples require setting up either the specific class you'll be use or the Base object before use:

ConstantContact::Base.user = 'user'
ConstantContact::Base.api_key = 'api-key'
ConstantContact::Base.password = 'password'

Find Lists

ConstantContact::List.find :all

Find A Contact

ConstantContact::Contact.find(:first, :params => {:email => ''})
ConstantContact::Contact.find_by_email('') # => same as previous line

Create a Contact (with rescue if it already exists)

ConstantContact::Base.user = 'user'
ConstantContact::Base.api_key = 'api-key'
ConstantContact::Base.password = 'password'

# Contact not found. Create it.
  @contact =
    :email_address => "",
    :first_name => "jon",
    :last_name => "smith"
rescue ActiveResource::ResourceConflict => e
  # contact already exists
  puts 'Contact already exists. Saving contact failed.'
  puts e

Find a Contact By Email Address, Check if They're a Member of the Default List

c = ConstantContact::Contact.find_by_email('')
@contact = ConstantContact::Contact.find(@contact.int_id)
puts 'In default contact list.' if @contact.contact_lists.include?(1) # contact_lists is an array of list ids

Copyright (c) 2009 Timothy Case, released under the MIT license

Something went wrong with that request. Please try again.