Close and Go BackBack to Viget

Introducing: EmailLabsClient

David Eisinger
David Eisinger, Web Developer, July 31, 2008 0

On my latest project, the client is using EmailLabs to manage their mailing lists. To simplify interaction with their system, we’ve created EmailLabsClient, a small Ruby client for the EmailLabs API. The core of the program is the send_request method:

def self.send_request(request_type, activity)
  xml = Builder::XmlMarkup.new :target => (input = '')
  xml.instruct!
  xml.DATASET do
    xml.SITE_ID SITE_ID
    yield xml
  end
  Net::HTTP.post_form(URI.parse(ENDPOINT),
    :type => request_type, :activity => activity,
    :input => input)
end

Then you can make API requests like this:

def self.subscribe_user(mailing_list, email_address)
  send_request('record', 'add') do |body|
    body.MLID mailing_list
    body.DATA email_address, :type => 'email'
  end
end

If you find yourself needing to work with an EmailLabs mailing list, check it out. At the very least, you should get a decent idea of how to interact with their API. It’s up on GitHub, so if you add any functionality, send those patches our way.

Trackback URL: http://www.viget.com/trackback/1213/

Comments for this entry were closed after 60 days.

Name:

Email:

URL:

Not a robot? Prove it by entering the word below.


Remember my personal information

Notify me of follow-up comments?

A Development Community for Viget Labs and Beyond

Every team member here at Viget Labs strives to be an innovator. We members of the development team are no different - that's why we're constantly engaging in community discussions and exploring the unknown that is the next generation of open-source web applications.

Viget Is Hiring!

Viget has job openings for Ruby Developers, Interns, and Front-End Developers. Learn More »

Recent Comments

I think that polymorphic_url(@commentable, :anchor => “comment_#{@comment.id}") should work. You can also refactor the “comment_#{@comment.id}” to a separated method, like dom_id, which returns the dom identifier of the comment.